laravel use scope code example
Example 1: laravel scope relationship
class User extends Model {
public function scopePopular($query)
{
return $query->where('votes', '>', 100);
}
public function scopeWomen($query)
{
return $query->whereGender('W');
}
}
Example 2: laravel scope relationship
class User extends Model {
protected function getDateFormat()
{
return 'U';
}
}