add if condition in model laravel code example
Example 1: laravel 8 orderby
$flights = App\Models\Flight::where('active', 1)
->orderBy('name', 'desc')
->take(10)
->get();
Example 2: query builder laravel
use Illuminate\Database\Eloquent\Builder;
public function scopeFakePersons(Builder $query): Builder
{
return $query->where('is_fake', 1);
}