Answers for "laravel relations search"

PHP
1

laravel search data relationship

$data = Subcategory::with(["category"])
                            ->where('name','like', '%'.$this->searchData.'%')
                            ->orWhereHas('category', function($query){$query->where('name', 'like', '%'.$this->searchData.'%');})
                            ->orderBy($this->orderByData, $this->orderByAsc ? 'asc' : 'desc')
                            ->paginate($this->showData);
Posted by: Guest on September-28-2021
0

laravel relations find

use App\Models\User;

$user = User::find(1);

foreach ($user->roles as $role) {
    //
}
Posted by: Guest on June-10-2021

Code answers related to "laravel relations search"

Browse Popular Code Answers by Language