laravel timestamps model code example

Example 1: laravel model without timestamps

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Post extends Model
{
    public $timestamps = false;

    //
}

Example 2: laravel current timestamp

use Carbon\Carbon;
$current_date_time = Carbon::now()->toDateTimeString(); // Produces something like "2019-03-11 12:25:00"

Example 3: update query in laravel eloquent

$data = DB::table('cart')
                ->where('crt_id', $id)
               ->update(['crt_status' =>'0']);

Example 4: timestamp in model laravel

$user = User::find(1);
$user->profile_views_count = 123;
$user->timestamps = false;
$user->save();