0

Adding data into mongodb with insert method :

   $published_at = $faker->dateTimeBetween($startDate = '-200 days', $endDate = 'now', config('app.timezone'));

   $todayEnd = Carbon::now(config('app.timezone'));

   $data[] = [
      ...
      'published_at' => !empty($published_at->date) ? $published_at->date: null,
      'created_at' => $todayStart,

But checking in I see that published_at has null value and created_at has “{}” value. Which way is valid ?

Laravel 9
jenssegers/mongodb 3

Thanks in advance!

Petro Gromovo
  • 1,755
  • 5
  • 33
  • 91
  • 1
    jenssegers/mongodb adds mongodb support to Eloquent so you can use Eloquent as normal – apokryfos Jul 30 '22 at 07:43
  • 1
    Try adding `published_at` and `created_at` to the `fillable` property of the model if not added. – iamab.in Jul 30 '22 at 07:53
  • If I replace Model::insert method with Model::create yes, then dates in carbon format are written ok. I would prefer to use Model::insert as it is quicker and I have a big set of data. Is there is a way to pass valid date value with Model::insert ? – Petro Gromovo Jul 31 '22 at 07:53

0 Answers0