laravel eloquent where in code example
Example 1: laravel findorfail
$model = App\Flight::where('name', 'Mike')->firstOrFail();
Example 2: eloquent where in
$users = DB::table('users')->whereIn('id', array(1, 2, 3))->get()
Example 3: where () laravel Eloquent
//los signos de igualdad pueden ser: ">=", "<=", "=", ">", "<"
$user = User::where("estado","=",1)->find(10);
Example 4: laravel eloquent remove from db
$res=User::where('id',$id)->delete();
Example 5: larave Soft Deletes
Schema::table('flights', function (Blueprint $table) {
$table->softDeletes();
});
Example 6: laravel eloquent remove from db
public function destroy($id){
$res=User::find($id)->delete();
if ($res){
$data=[
'status'=>'1',
'msg'=>'success'
];
}else{
$data=[
'status'=>'0',
'msg'=>'fail'
];
return response()->json($data);