I have a task model and I am trying to do a simple create to test something in one of my observer classes. Here's my create code.
private function generateTasks(Event $event)
{
$tasks = [];
$tasks[] = [
'event_id' => $event->id,
'title' => 'This is a test',
'description' => 'this is a description',
'due_on' => Carbon::now()->addDays(14)
];
dump(Task::all());
// foreach ($tasks as $task) {
$task = Task::create([
'event_id' => $event->id,
'title' => 'This is a test',
'description' => 'this is a description',
'due_on' => Carbon::now()->addDays(14)
]);
if ($task->save()) {
echo "Saved";
}
else {
echo "NO SAVE";
}
dump($task);
// }
dd($tasks, "DONE");
}
And the output is below:
When I look at the database the table remains at 120 rows. This is really odd because it says it's saving. When I grab all the tasks you can see in the output it has 120 rows. If you look at my latest output id you'll see that I am up to 133.
Any ideas what is going on here?
UPDATE:
My fillables:
protected $fillable = [
'title', 'description', 'due_on', 'event_id', 'completed'
];
Completed has a default of false.
My table looks like this to give you guys an idea: