1$result = Marriage::where('name','LIKE','%'.$email_or_name.'%')
2 ->orWhere('email','LIKE','%'.$email_or_name.'%')
3 ->get();
1 ->whereHas('translation', function ($query) use ($name){
2 $query->where('name', 'like', $name);
3 }, '>=', 10)
4
1$searchTerm ='milad zamir Abc';
2$reservedSymbols = ['-', '+', '<', '>', '@', '(', ')', '~'];
3$searchTerm = str_replace($reservedSymbols, ' ', $searchTerm);
4
5$searchValues = preg_split('/\s+/', $searchTerm, -1, PREG_SPLIT_NO_EMPTY);
6
7$res = User::where(function ($q) use ($searchValues) {
8 foreach ($searchValues as $value) {
9 $q->orWhere('name', 'like', "%{$value}%");
10 $q->orWhere('family_name', 'like', "%{$value}%");
11 }
12})->get();
1// Retrieve a model by its primary key...
2$flight = App\Models\Flight::find(1);
3
4// Retrieve the first model matching the query constraints...
5$flight = App\Models\Flight::where('active', 1)->first();
6
7// Shorthand for retrieving the first model matching the query constraints...
8$flight = App\Models\Flight::firstWhere('active', 1);
1return Destination::orderByDesc(
2 Flight::select('arrived_at')
3 ->whereColumn('destination_id', 'destinations.id')
4 ->orderBy('arrived_at', 'desc')
5 ->limit(1)
6)->get();
1The find Method
2If you are overriding the find method in your own models and calling parent::find() within your custom method, you should now change it to call the find method on the Eloquent query builder:
3
4public static function find($id, $columns = ['*'])
5{
6 $model = static::query()->find($id, $columns);
7
8 // ...
9
10 return $model;
11}