app\models\Song::scopeInDirectory PHP Method

scopeInDirectory() public method

Scope a query to only include songs in a given directory.
public scopeInDirectory ( Builder $query, string $path ) : Builder
$query Illuminate\Database\Eloquent\Builder
$path string Full path of the directory
return Illuminate\Database\Eloquent\Builder
    public function scopeInDirectory($query, $path)
    {
        // Make sure the path ends with a directory separator.
        $path = rtrim(trim($path), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
        return $query->where('path', 'LIKE', "{$path}%");
    }