diff options
| -rw-r--r-- | app/Http/Controllers/QuoteController.php | 68 | ||||
| -rw-r--r-- | app/Http/Requests/StoreQuoteRequest.php | 28 | ||||
| -rw-r--r-- | app/Http/Requests/UpdateQuoteRequest.php | 28 | ||||
| -rw-r--r-- | app/Models/Quote.php | 18 | ||||
| -rw-r--r-- | database/factories/QuoteFactory.php | 23 | ||||
| -rw-r--r-- | database/migrations/2025_06_08_022018_create_quotes_table.php | 31 | ||||
| -rw-r--r-- | database/migrations/99999_pivots.php | 7 | ||||
| -rw-r--r-- | database/seeders/QuoteSeeder.php | 17 | ||||
| -rw-r--r-- | public/js/lib.js | 35 | ||||
| -rw-r--r-- | public/js/main.js | 30 |
10 files changed, 267 insertions, 18 deletions
diff --git a/app/Http/Controllers/QuoteController.php b/app/Http/Controllers/QuoteController.php new file mode 100644 index 0000000..0803937 --- /dev/null +++ b/app/Http/Controllers/QuoteController.php @@ -0,0 +1,68 @@ +<?php + +namespace App\Http\Controllers; + +use App\Http\Requests\StoreQuoteRequest; +use App\Http\Requests\UpdateQuoteRequest; +use App\Models\Quote; + +class QuoteController extends Controller +{ + /** + * Display a listing of the resource. + */ + public function index() + { + // + } + + /** + * Show the form for creating a new resource. + */ + public function create() + { + // + } + + /** + * Store a newly created resource in storage. + */ + public function store(StoreQuoteRequest $request) + { + // + $quote = Quote::create($request->validated()); + + } + + /** + * Display the specified resource. + */ + public function show(Quote $quote) + { + // + } + + /** + * Show the form for editing the specified resource. + */ + public function edit(Quote $quote) + { + // + } + + /** + * Update the specified resource in storage. + */ + public function update(UpdateQuoteRequest $request, Quote $quote) + { + // + } + + /** + * Remove the specified resource from storage. + */ + public function destroy(Quote $quote) + { + // + } +} diff --git a/app/Http/Requests/StoreQuoteRequest.php b/app/Http/Requests/StoreQuoteRequest.php new file mode 100644 index 0000000..e9859fb --- /dev/null +++ b/app/Http/Requests/StoreQuoteRequest.php @@ -0,0 +1,28 @@ +<?php + +namespace App\Http\Requests; + +use Illuminate\Foundation\Http\FormRequest; + +class StoreQuoteRequest extends FormRequest +{ + /** + * Determine if the user is authorized to make this request. + */ + public function authorize(): bool + { + return false; + } + + /** + * Get the validation rules that apply to the request. + * + * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string> + */ + public function rules(): array + { + return [ + // + ]; + } +} diff --git a/app/Http/Requests/UpdateQuoteRequest.php b/app/Http/Requests/UpdateQuoteRequest.php new file mode 100644 index 0000000..93804a8 --- /dev/null +++ b/app/Http/Requests/UpdateQuoteRequest.php @@ -0,0 +1,28 @@ +<?php + +namespace App\Http\Requests; + +use Illuminate\Foundation\Http\FormRequest; + +class UpdateQuoteRequest extends FormRequest +{ + /** + * Determine if the user is authorized to make this request. + */ + public function authorize(): bool + { + return false; + } + + /** + * Get the validation rules that apply to the request. + * + * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string> + */ + public function rules(): array + { + return [ + // + ]; + } +} diff --git a/app/Models/Quote.php b/app/Models/Quote.php new file mode 100644 index 0000000..f340ba9 --- /dev/null +++ b/app/Models/Quote.php @@ -0,0 +1,18 @@ +<?php + +namespace App\Models; + +use Illuminate\Database\Eloquent\Factories\HasFactory; +use Illuminate\Database\Eloquent\Model; + +class Quote extends Model +{ + /** @use HasFactory<\Database\Factories\QuoteFactory> */ + use HasFactory; + + public $fillable = [ + 'author', + 'text', + 'source', + ]; +} diff --git a/database/factories/QuoteFactory.php b/database/factories/QuoteFactory.php new file mode 100644 index 0000000..655907a --- /dev/null +++ b/database/factories/QuoteFactory.php @@ -0,0 +1,23 @@ +<?php + +namespace Database\Factories; + +use Illuminate\Database\Eloquent\Factories\Factory; + +/** + * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Quote> + */ +class QuoteFactory extends Factory +{ + /** + * Define the model's default state. + * + * @return array<string, mixed> + */ + public function definition(): array + { + return [ + // + ]; + } +} diff --git a/database/migrations/2025_06_08_022018_create_quotes_table.php b/database/migrations/2025_06_08_022018_create_quotes_table.php new file mode 100644 index 0000000..6ea4200 --- /dev/null +++ b/database/migrations/2025_06_08_022018_create_quotes_table.php @@ -0,0 +1,31 @@ +<?php + +use Illuminate\Database\Migrations\Migration; +use Illuminate\Database\Schema\Blueprint; +use Illuminate\Support\Facades\Schema; + +return new class extends Migration +{ + /** + * Run the migrations. + */ + public function up(): void + { + Schema::create('quotes', function (Blueprint $table) { + $table->id(); + $table->timestamps(); + $table->string('author')->nullable(); + $table->string('text')->nullable(); + $table->string('source')->nullable(); + + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('quotes'); + } +}; diff --git a/database/migrations/99999_pivots.php b/database/migrations/99999_pivots.php index 5cae45a..edd497f 100644 --- a/database/migrations/99999_pivots.php +++ b/database/migrations/99999_pivots.php @@ -42,6 +42,12 @@ return new class extends Migration $table->integer('role_id')->unsigned()->index(); $table->foreign('role_id')->references('id')->on('roles')->onDelete('cascade'); }); + Schema::create('tag_quote', function (Blueprint $table) { + $table->integer('quote_id')->unsigned()->index(); + $table->foreign('quote_id')->references('id')->on('quotes')->onDelete('cascade'); + $table->integer('tag_id')->unsigned()->index(); + $table->foreign('tag_id')->references('id')->on('tags')->onDelete('cascade'); + }); } /** @@ -53,6 +59,7 @@ return new class extends Migration Schema::dropIfExists('file_tag'); Schema::dropIfExists('quest_tag'); Schema::dropIfExists('tag_writing'); + Schema::dropIfExists('tag_quote'); //Schema::dropIfExists('role_user'); } }; diff --git a/database/seeders/QuoteSeeder.php b/database/seeders/QuoteSeeder.php new file mode 100644 index 0000000..f237fce --- /dev/null +++ b/database/seeders/QuoteSeeder.php @@ -0,0 +1,17 @@ +<?php + +namespace Database\Seeders; + +use Illuminate\Database\Console\Seeds\WithoutModelEvents; +use Illuminate\Database\Seeder; + +class QuoteSeeder extends Seeder +{ + /** + * Run the database seeds. + */ + public function run(): void + { + // + } +} diff --git a/public/js/lib.js b/public/js/lib.js index 770efe5..e323a32 100644 --- a/public/js/lib.js +++ b/public/js/lib.js @@ -12,4 +12,39 @@ class AppSocket extends WebSocket { } } +export class Client extends AppSocket { + serverURL: string; + + constructor(serverURL: string) { + super(serverURL); + this.serverURL = serverURL; + this.on('open', this.onopen.bind(this)); + } + + onopen = (event: WebSocket.event)=>{ + console.log('Connected to server'); + // Send a test message to the server. todo this will be able to be inputted from user + + const myState = { + type: 'clientState', + payload: { + id: '123', + name: 'test client', + timestamp: Date.now(), + } + }; + this.send({data: 'yo'}); + console.log('Sent message:'); + } + onclose = ()=>{ + console.log('disconnected'); + } + onerror = (error: any)=>{ + console.error('error', error) + } + handleMessage(event: any){ + console.log('message'); + } +} + export { AppSocket };
\ No newline at end of file diff --git a/public/js/main.js b/public/js/main.js index fcaa512..fecb320 100644 --- a/public/js/main.js +++ b/public/js/main.js @@ -225,35 +225,29 @@ function connectWebSocket(){ secure: true, rejectUnauthorized: false });*/ - socket.on('connect_error', (err) => { + socket.onerror = (err)=>{ console.log('connection error'); console.log(err); //TODO $('').textContent = err; - }); - socket.on('connect_failed', (err) => { - console.log('conn failed'); - console.log(err); - //TODO $('').textContent = err; - }); - socket.on('disconnect', (err) => { + } + socket.onclose = (err) => { console.log('disconnected'); console.log(err); //TODO $('').textContent = err; - }); - socket.on('connect', (err) => { + } + socket.onopen = (err) => { log('connected'); if (err) console.log(err); //TODO $('').textContent = 'Connected'; socket.pingTimeout = 1000; socket.pingInterval = 500; - }); - socket.on('open', (event) => { - log('connected'); - log(event); - //TODO $('').textContent = 'Connected'; - socket.pingTimeout = 1000; - socket.pingInterval = 500; - }); + } + + socket.onmessage = (msg) => { + //console.log(msg); + + } + socket.on('syncCanvas', (data) => { //TODO appShapes = data.shapes; |
