コード例 #1
0
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot(Guard $auth)
 {
     view()->composer('*', function ($view) {
         $pages = Page::orderBy('position', 'asc')->get();
         $view->with('pages', $pages);
     });
     view()->composer('*', function ($view) {
         $view->with('currentUser', Auth::user());
     });
     view()->composer('sidebar.special', function ($view) {
         $specialProduct = Product::where('special', 1)->get();
         $view->with('specialProduct', $specialProduct);
     });
     view()->composer('sidebar.admin', function ($view) {
         $today = \Carbon\Carbon::today();
         $orders = DB::table('orders')->where('dateOrdered', '=', $today)->where('status_id', '>', 1)->count('id');
         $view->with('orders', $orders);
     });
     view()->composer('sidebar.admin', function ($view) {
         $today = date('l');
         $hours = DB::table('hours')->where('day', $today)->value('hours');
         $view->with('hours', $hours);
     });
     view()->composer('sidebar.admin', function ($view) {
         $batches = Batch::where('proddate', \Carbon\Carbon::today())->count();
         $view->with('batches', $batches);
     });
     view()->composer('sidebar.admin', function ($view) {
         $date = date('Y-m-d');
         $shift = Shift::where('date', $date)->pluck('id');
         $employeees = Shift::find($shift)->users()->count();
         $view->with('employeees', $employeees);
     });
     view()->composer('sidebar.special', function ($view) {
         $categories = Category::all();
         $view->with('categories', $categories);
     });
     view()->composer('*', function ($view) use($auth) {
         $user = Auth::user();
         if (Auth::user()) {
             $cart = DB::table('orders')->select('id')->where('status_id', '=', 1)->where('user_id', '=', $user->id)->value('id');
             $cartItems = DB::table('order_products')->where('order_id', '=', $cart)->sum('quantity');
             $view->with('cartItems', $cartItems);
         }
     });
 }
コード例 #2
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $pages = Page::orderBy('sorter')->paginate(10);
     return view('admin.page.index', ['pages' => $pages]);
 }
コード例 #3
0
 /**
  * Show the application dashboard to the user.
  *
  * @return Response
  */
 public function index()
 {
     $page = Page::orderBy('updated_at', 'desc')->get();
     return view('home')->withPages($page);
 }
コード例 #4
0
 /**
  * Display user account dashboard.
  *
  * @return Response
  */
 public function account()
 {
     $user = Auth::user();
     $pages = Page::orderBy('updated_at', 'desc')->take(5)->get();
     $portfolio_items = Portfolio::orderBy('updated_at', 'desc')->take(5)->get();
     return view('user.account', ['user' => $user, 'pages' => $pages, 'portfolio_items' => $portfolio_items]);
 }