/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { // $file_categories = FileCategory::get(); $heading = 'Manage File Categories'; return view($this->view_all, array('file_categories' => $file_categories, 'heading' => $heading)); }
/** * FILES/IMAGES HANDLING * */ public function index(Request $request) { $heading = 'List All Files and Images'; $querystringArray = $request->input(); # does session contains a filter value? if ($request->has('bycategory')) { // get only FILES with this specific file_category id $file_category = FileCategory::find($request->input('bycategory')); if ($file_category) { $heading = 'Show Files of type "' . $file_category->name . '"'; // get all files of this category $files = $file_category->files()->paginate(18)->appends($querystringArray); } } if ($request->has('newest')) { $heading = 'Recently added files'; $files = File::orderBy('id', 'desc')->paginate(18); } // default: show all files if (!isset($files)) { $files = File::paginate(18); } // URL contains ...?item_id=xxx (needed in order to add an existing file to an item) $item_id = 0; if ($request->has('item_id')) { $item_id = $request->item_id; $heading = 'Select a file for the Plan Item'; } // get list of file categories $file_categories = FileCategory::get(); // for pagination, always append the original query string $files = $files->appends($querystringArray); return view('admin.files', ['files' => $files, 'item_id' => $item_id, 'heading' => $heading, 'file_categories' => $file_categories]); }