public function scopeFilteredByType(Builder $query, $type = null)
    {
        $type = is_null($type) ? request('f', 'all') : $type;

        if (in_array($type, ['audio', 'document', 'image', 'video', 'embedded']))
        {
            $query->whereType($type);
        }

        return $query;
    }