sorting first commit

This commit is contained in:
Milos Holba
2020-12-05 17:08:57 +01:00
parent 6bc84d4b25
commit ec6087a03c
9 changed files with 274 additions and 192 deletions
+12 -1
View File
@@ -9,6 +9,7 @@ use Illuminate\Support\Str;
use Laravel\Scout\Searchable;
use TeamTNT\TNTSearch\Indexer\TNTIndexer;
use \Illuminate\Database\Eloquent\SoftDeletes;
use Kyslik\ColumnSortable\Sortable;
/**
* App\FileManagerFile
@@ -55,7 +56,7 @@ use \Illuminate\Database\Eloquent\SoftDeletes;
*/
class FileManagerFile extends Model
{
use Searchable, SoftDeletes;
use Searchable, SoftDeletes , Sortable;
public $public_access = null;
@@ -71,6 +72,16 @@ class FileManagerFile extends Model
'metadata' => 'array',
];
/**
* Sortable columns
*
* @var string[]
*/
public $sortable = [
'name',
'created_at',
];
/**
* Set routes with public access
*
+12 -1
View File
@@ -11,6 +11,7 @@ use RecursiveArrayIterator;
use RecursiveIteratorIterator;
use TeamTNT\TNTSearch\Indexer\TNTIndexer;
use \Illuminate\Database\Eloquent\SoftDeletes;
use Kyslik\ColumnSortable\Sortable;
/**
* App\FileManagerFolder
@@ -61,7 +62,7 @@ use \Illuminate\Database\Eloquent\SoftDeletes;
*/
class FileManagerFolder extends Model
{
use Searchable, SoftDeletes;
use Searchable, SoftDeletes , Sortable;
protected $guarded = [
'id'
@@ -71,6 +72,16 @@ class FileManagerFolder extends Model
'items', 'trashed_items'
];
/**
* Sortable columns
*
* @var string[]
*/
public $sortable = [
'name',
'created_at',
];
/**
* Index folder
*
@@ -148,13 +148,15 @@ class BrowseController extends Controller
$folders = FileManagerFolder::with(['parent', 'shared:token,id,item_id,permission,protected,expire_in'])
->where('user_id', $user_id)
->where('parent_id', $unique_id)
->orderBy('created_at', 'DESC')
// ->orderBy('created_at', 'DESC')
->sortable(['name', 'DESC'])
->get();
$files = FileManagerFile::with(['parent', 'shared:token,id,item_id,permission,protected,expire_in'])
->where('user_id', $user_id)
->where('folder_id', $unique_id)
->orderBy('created_at', 'DESC')
// ->orderBy('created_at', 'DESC')
->sortable(['name', 'DESC'])
->get();
// Collect folders and files to single array