Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

laravel wherehas with condition

public function index()
{
    $countryName = 'Brazil';
    $users = User::with('country')
		->whereHas('country', function (Builder $query) use($countryName) {
			$query->where('name', 'like', "%{$countryName}%");
		})
      ->get();
}
Source by www.itsolutionstuff.com #
 
PREVIOUS NEXT
Tagged: #laravel #wherehas #condition
ADD COMMENT
Topic
Name
2+6 =