Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • #220

    Hi I have case where where I added records in my database, all the data are being inserted except the created_at and update_at. How to solve this issue?


    Its a common problem. It’s most likely because you use query builder to insert your records. The created_at and updated_at will only automatically be inserted if you are using eloquent model.

    You can still use query builder but you have to first insert the Carbon package and then use the now method like this:

    use Carbon\Carbon;
    use Illuminate\Support\Facades\DB;

    DB::table(‘name’)-> insert([
    ‘created_at’ => Carbon::now(),
    ‘updated_at’ => Carbon::now()


    Yeah it works. Thank you

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.