where laravel eloquent code example
Example 1: laravel delete where
DB::table('users')->where('id', $id)->delete();
Example 2: laravel fillable
protected $fillable = [
'title',
'slug',
'body',
'image',
'published',
'comments_open'
];
Example 3: fresh laravel
$flight = Flight::where('number', 'FR 900')->first();
$flight->number = 'FR 456';
$flight->refresh();
$flight->number;
Example 4: eloquent where in
$users = DB::table('users')->whereIn('id', array(1, 2, 3))->get()
Example 5: laravel create or update
$flight = App\Models\Flight::updateOrCreate(
['departure' => 'Oakland', 'destination' => 'San Diego'],
['price' => 99, 'discounted' => 1]
);
Example 6: where () laravel Eloquent
$user = User::where("estado","=",1)->find(10);