Example #1
0
 public function index()
 {
     if (!Auth::check()) {
         return LoginController::getIndex();
     }
     LoginController::updateUserPermissions();
     //why not
     # Trail
     Trail::clear();
     $tables = array_where(config('center.tables'), function ($key, $value) {
         return !$value->hidden && LoginController::checkPermission($value->name, 'view');
     });
     $groups = $objects = [];
     foreach ($tables as $table) {
         $latest = DB::table($table->name)->leftJoin(config('center.db.users') . ' as u2', $table->name . '.updated_by', '=', 'u2.id')->select('u2.name as updated_name', $table->name . '.updated_at')->orderBy($table->name . '.updated_at', 'desc')->first();
         if (!isset($groups[$table->list_grouping])) {
             $groups[$table->list_grouping] = [];
         }
         $groups[$table->list_grouping][] = (object) ['title' => $table->title, 'list_grouping' => $table->list_grouping, 'link' => action('\\LeftRight\\Center\\Controllers\\RowController@index', $table->name), 'updated_name' => isset($latest->updated_name) ? $latest->updated_name : '', 'updated_at' => isset($latest->updated_at) ? $latest->updated_at : '', 'count' => number_format(DB::table($table->name)->count())];
     }
     foreach ($groups as $group) {
         $objects = array_merge($objects, $group);
     }
     $table = new Table();
     $table->rows($objects);
     $table->column('title', 'string', trans('center::site.table'));
     $table->column('count', 'integer', trans('center::site.count'));
     $table->column('updated_name', 'updated_name', trans('center::site.updated_name'));
     $table->column('updated_at', 'updated_at', trans('center::site.updated_at'));
     $table->groupBy('list_grouping');
     $table = $table->draw('tables');
     return view('center::tables.index', compact('table'));
 }
Example #2
0
 public function handle($request, Closure $next)
 {
     if (!Auth::check()) {
         return LoginController::getIndex();
     }
     return $next($request);
 }