Search
 
SCRIPT & CODE EXAMPLE
 

PHP

laravel where has

use IlluminateDatabaseEloquentBuilder;

// Retrieve posts with at least one comment containing words like foo%...
$posts = AppPost::whereHas('comments', function (Builder $query) {
    $query->where('content', 'like', 'foo%');
})->get();

// Retrieve posts with at least ten comments containing words like foo%...
$posts = AppPost::whereHas('comments', function (Builder $query) {
    $query->where('content', 'like', 'foo%');
}, '>=', 10)->get();
Comment

laravel with has

public function index()
{
    $countryName = 'Brazil';
    $users = User::with('country')
		->whereHas('country', function (Builder $query) use($countryName) {
			$query->where('name', 'like', "%{$countryName}%");
		})
      ->get();
}
Comment

PREVIOUS NEXT
Code Example
Php :: required field in laravel admin 
Php :: convert matrix row to column php 
Php :: escape url string php 
Php :: vue mouseover 
Php :: asset not working in laravel 
Php :: get cart item by cart item key woocommerce 
Php :: capitalize in php 
Php :: load php in html 
Php :: php from 
Php :: current user laravel 
Php :: remove repeated columns laravel 
Php :: causes of 419 error lravel 
Php :: php get query params 
Php :: PHP | get client ip simple 
Php :: add another field in existing migration laravel 
Php :: php why " " not new line 
Php :: get first element of array php 
Php :: array push foreach php 
Php :: relative path php 
Php :: run python script from batch file with arguments 
Php :: php rename files in directory 
Php :: How to insert time in table using CodeIgniter 
Php :: wordpress global variable not working 
Php :: php check if query returns results 
Php :: Call to undefined method IlluminateSessionStore::set() 
Php :: joomla login link 
Php :: nav active in laravel 
Php :: laravel check if table has column 
Php :: is users logged in laravel blade 
Php :: install phpUnit in php by composer 
ADD CONTENT
Topic
Content
Source link
Name
7+1 =