“Consulta de búsqueda en Laravel” Código de respuesta

Laravel elocuente consulta de búsqueda 2020

$result = Marriage::where('name','LIKE','%'.$email_or_name.'%')
                ->orWhere('email','LIKE','%'.$email_or_name.'%')
                ->get();
Zeevx

Consulta de búsqueda en Laravel

$searchTerm ='milad zamir Abc';
$reservedSymbols = ['-', '+', '<', '>', '@', '(', ')', '~'];
$searchTerm = str_replace($reservedSymbols, ' ', $searchTerm);

$searchValues = preg_split('/\s+/', $searchTerm, -1, PREG_SPLIT_NO_EMPTY);

$res = User::where(function ($q) use ($searchValues) {
	foreach ($searchValues as $value) {
    $q->orWhere('name', 'like', "%{$value}%");
    $q->orWhere('family_name', 'like', "%{$value}%");
    }
})->get();
Zamir

¿Dónde está la búsqueda de Laravel?

                ->whereHas('translation', function ($query) use ($name){
                    $query->where('name', 'like', $name);
                }, '>=', 10)
Sleepy Shrew

Laravel Find Query

// Retrieve a model by its primary key...
$flight = App\Models\Flight::find(1);

// Retrieve the first model matching the query constraints...
$flight = App\Models\Flight::where('active', 1)->first();

// Shorthand for retrieving the first model matching the query constraints...
$flight = App\Models\Flight::firstWhere('active', 1);
Suhail Khan

Laravel "Query ()-> encontrar"

The find Method
If 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:

public static function find($id, $columns = ['*'])
{
    $model = static::query()->find($id, $columns);

    // ...

    return $model;
}
Exuberant Eel

Laravel Find Query

return Destination::orderByDesc(
    Flight::select('arrived_at')
        ->whereColumn('destination_id', 'destinations.id')
        ->orderBy('arrived_at', 'desc')
        ->limit(1)
)->get();
Suhail Khan

Respuestas similares a “Consulta de búsqueda en Laravel”

Preguntas similares a “Consulta de búsqueda en Laravel”

Más respuestas relacionadas con “Consulta de búsqueda en Laravel” en PHP

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código