Search
 
SCRIPT & CODE EXAMPLE
 

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();
}
Comment

PREVIOUS NEXT
Code Example
Php :: php exercises and solutions 
Php :: how to get the number of days in the current month using carbon 
Php :: php needle haystack 
Php :: wp debug 
Php :: how to mask phone number in php 
Php :: php trim string if longer than 
Php :: capitalize php 
Php :: how to add attributes to an object in php 
Php :: php foreach 
Php :: laravel database select 
Php :: php array json encode key and value 
Php :: return view controller laravel 
Php :: laravel blade upper case 
Php :: date and time in php 
Php :: yum install php-mysql 
Php :: How to get a substring between two strings in PHP? 
Php :: php basename from path 
Php :: remove cache from cpanle larael 
Php :: php show active page 
Php :: laravel elasticsearch migration in laravel 
Php :: 404 page in laravel 
Php :: strcasecmp php 
Php :: laravel query string 
Php :: php strftime 
Php :: php check if headers already sent 
Php :: get blog page url in wordpress 
Php :: Laravel required if it meet some value from another field 
Php :: wordpress register post type 
Php :: ubuntu fopen failed to open stream: Permission denied 
Php :: php switch statement 
ADD CONTENT
Topic
Content
Source link
Name
2+1 =