update relationship laravel code example
Example 1: update query in laravel eloquent
$data = DB::table('cart')
->where('crt_id', $id)
->update(['crt_status' =>'0']);
Example 2: laravel eloquent associate
$account = App\Account::find(10);
$user->account()->associate($account);
$user->save();
Example 3: laravel property
$user = User::create(array('name' => 'John'));
$user = User::firstOrCreate(array('name' => 'John'));
$user = User::firstOrNew(array('name' => 'John'));
Example 4: eloquent relationships
$roles = App\User::find(1)->roles()->orderBy('name')->get();
Example 5: laravel property
$user = User::create(array('name' => 'John'));
$user = User::firstOrCreate(array('name' => 'John'));
$user = User::firstOrNew(array('name' => 'John'));