You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It should take a minute to download and create all necessary files.
41
-
Once everything is done, you can check that everything is correct so far:
40
+
It should take a minute to download and create all necessary files.
41
+
Once everything is done, you can check that everything is correct so far. Go the project folder and run database migrations:
42
42
43
43
~~~php
44
44
cd gantt-laravel-app
45
+
php artisan migrate
46
+
~~~
47
+
48
+
Now, you can run the server:
49
+
50
+
~~~php
45
51
php artisan serve
46
52
~~~
47
53
@@ -323,7 +329,7 @@ The Task model will look as in:
323
329
~~~php title="/app/Models/Task.php"
324
330
<?php
325
331
326
-
namespace App;
332
+
namespace App\Models;
327
333
328
334
use Illuminate\Database\Eloquent\Model;
329
335
@@ -343,7 +349,7 @@ And the Link model doesn't need any changes:
343
349
~~~php title="/app/Models/Link.php"
344
350
<?php
345
351
346
-
namespace App;
352
+
namespace App\Models;
347
353
348
354
use Illuminate\Database\Eloquent\Model;
349
355
@@ -509,6 +515,34 @@ class TaskController extends Controller
509
515
}
510
516
~~~
511
517
518
+
519
+
#### Configuring the Task model
520
+
521
+
Before the controller methods will work, we need to configure the `Task` model to allow mass assignment. [Laravel's mass assignment](https://laravel.com/docs/11.x/eloquent#mass-assignment) protection requires you to explicitly specify which attributes can be filled using the `create()` and `update()` methods.
522
+
Update your Task model to include the `$fillable` property:
The `$fillable` array specifies which fields can be mass-assigned. This is a security feature that protects against unwanted fields being updated through user input.
543
+
544
+
545
+
512
546
And a [route](https://laravel.com/docs/12.x/controllers#resource-controllers) for it:
513
547
514
548
@@ -577,6 +611,24 @@ class LinkController extends Controller
577
611
}
578
612
~~~
579
613
614
+
#### Configuring the Link model
615
+
616
+
Similarly to the Task model, we need to configure the Link model for mass assignment:
0 commit comments