src/Media.php
public function scopeInDirectory(Builder $q, $disk, $directory, $recursive = false)
    {
        $q->where('disk', $disk);
        if ($recursive) {
            $directory = str_replace(['%', '_'], ['\%', '\_'], $directory);
            $q->where('directory', 'like', $directory.'%');
        } else {
            $q->where('directory', '=', $directory);
        }
    }
public function scopeInDirectory(Builder $q, $disk, $directory, $recursive = false)
    {
        $q->where('disk', $disk);
        if ($recursive) {
            $directory = str_replace(['%', '_'], ['\%', '\_'], $directory);
            $q->where('directory', 'like', $directory.'%');
        } else {
            $q->where('directory', '=', $directory);
        }
    }
public function scopeInDirectory ( Builder $ q , $ disk , $ directory , $ recursive = false ) { $ q -> where ( 'disk' , $ disk ) ; if ( $ recursive ) { $ directory = str_replace ( [ '%' , '_' ] , [ '\%' , '\_' ] , $ directory ) ; $ q -> where ( 'directory' , 'like' , $ directory . '%' ) ; } else { $ q -> where ( 'directory' , '=' , $ directory ) ; } }
Query scope for to find media in a particular directory.
@param  \Illuminate\Database\Eloquent\Builder  $q
@param  string                                 $disk      Filesystem disk to search in
@param  string                                 $directory Path relative to disk
@param  bool                                   $recursive (_optional_) If true, will find media in or under the specified directory
@return void
Query scope for to find media in a particular directory .