Home > Mobile >  Laravel schedule: creating new row in a table automatically
Laravel schedule: creating new row in a table automatically

Time:07-05

(Laravel framework) I'm trying to create new row automatically in a table using schedule inside the handle function but it's not adding the row to the table:

public function handle()
{
    Reserved::create([
              'book_id'=>1,
              'user_id'=>1
    ]);
}

the schedule is working when I try other things like deleting a row or sending emails... What can I do?

CodePudding user response:

You probably haven't added the $fillable property to your Reserved model class. This prevents the create method from storing a new instance.

See Documentation: https://laravel.com/docs/9.x/eloquent#mass-assignment

  • Related