Answers for "laravel "query()->find""

PHP
0

search query in 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();
Posted by: Guest on November-08-2020
0

laravel "query()->find"

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;
}
Posted by: Guest on August-11-2020
-1

laravel find query

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Flight extends Model
{
    //
}
Posted by: Guest on October-08-2020

Browse Popular Code Answers by Language