/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index(GamesRequest $request) { $games = Product::join('games as g', 'g.product_id', '=', 'id'); $games = $games->where('type', 'GAME'); $title = 'Game'; $heading = 'Game'; // platform if (!empty($request->platform)) { $games = $games->where('g.platform_id', Platform::where('name', $request->platform)->first()->id); $heading = $request->platform . ' ' . $heading + 's'; } // query if (!empty($request->q)) { $games = $games->where('name', 'LIKE', '%' . $request->q . '%'); } // sort if (!empty($request->sort)) { $games = $games->orderBy($request->sort, $request->order); } else { $games = $games->orderBy('g.updated_at', 'desc'); } // flash input $request->flash(); return view('games.index')->with('title', $title)->with('heading', $heading)->with('games', $games->paginate(env('PAGINATE'))); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index($type, VideosRequest $request) { $videos = Product::join('videos as v', 'v.product_id', '=', 'id'); switch ($type) { case "movies": $videos = $videos->where('type', 'MOVIE'); $title = 'Movies'; $heading = 'Movies'; break; case "series": $videos = $videos->where('type', 'SERIES'); $title = 'Series'; $heading = 'Series'; break; case "anime": $videos = $videos->where('type', 'ANIME'); $title = 'Anime'; $heading = 'Anime'; break; case "documentries": $videos = $videos->where('type', 'VIDEO'); $title = 'Documentries'; $heading = 'Documentries'; break; default: return redirect()->back(); } // language if (!empty($request->language)) { $videos = $videos->where('v.language_id', Language::where('name', $request->language)->first()->id); $heading = $request->language . ' ' . $heading; } // query if (!empty($request->q)) { $videos = $videos->where('name', 'LIKE', '%' . $request->q . '%'); } // sort if (!empty($request->sort)) { $videos = $videos->orderBy($request->sort, $request->order); } else { $videos = $videos->orderBy('v.release_date', 'desc'); } // flash input $request->flash(); return view('videos.index')->with('title', $title)->with('heading', $heading)->with('videos', $videos->paginate(env('PAGINATE')))->with('type', $type); }
public function products() { return Product::join('locations', 'locations.product_id', '=', 'products.id')->where('locations.user_id', $this->getKey()); }
}); Route::group(['prefix' => 'settings', 'namespace' => 'Settings\\Uoms', 'middleware' => ['auth', 'is_admin']], function () { Route::resource('uoms', 'UomsController'); }); Route::resource('paymentMethods', 'PaymentMethods\\PaymentMethodsController', ['middleware' => 'auth', 'is_user', 'is_admin']); Route::resource('paramPacs', 'ParamPacs\\ParamPacsController', ['middleware' => ['auth', 'is_user', 'is_admin']]); Route::resource('partners', 'Partners\\PartnersController', ['middleware' => ['auth', 'is_user', 'is_admin']]); Route::resource('taxs', 'Taxs\\TaxsController', ['middleware' => ['auth', 'is_user', 'is_admin']]); Route::group(['prefix' => 'settings', 'namespace' => 'Settings\\Certificatesats', 'middleware' => ['auth', 'is_admin']], function () { Route::resource('certificatesats', 'CertificatesatsController'); }); Route::group(['namespace' => 'Products', 'middleware' => ['auth', 'is_admin', 'is_user', 'is_sale']], function () { Route::pattern('products', '[0-9]+'); Route::get('products/searchCode/{ean13}', ['as' => 'products.searchCode', function ($ean13) { if (Request::ajax()) { $producto = Product::join('uoms', 'products.uom_id', '=', 'uoms.id')->where('ean13', $ean13)->select('products.*', 'uoms.name as umo_name')->get(); return $producto->toJson(); } }]); Route::get('products/report', 'ProductsController@report'); Route::get('products/reportmax', 'ProductsController@reportmax'); Route::get('products/reportmin', 'ProductsController@reportmin'); Route::resource('products', 'ProductsController'); }); Route::group(['namespace' => 'SaleOrders', 'middleware' => ['auth', 'is_admin', 'is_user', 'is_sale']], function () { Route::pattern('sales', '[0-9]+'); Route::resource('sales', 'SaleOrdersController'); }); Route::group(['namespace' => 'PurchaseOrders', 'middleware' => ['auth', 'is_admin', 'is_user', 'is_purchase']], function () { Route::pattern('purchases', '[0-9]+'); Route::resource('purchases', 'PurchaseOrdersController');
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $product = new Product(); Product::find($id)->delete(); $products = $product->join('categories', 'products.category_id', '=', 'categories.id')->select('products.title', 'products.description', 'products.cost_price', 'products.id', 'categories.name')->orderBy('products.title', asc)->get(); $category = new Category(); $categories = $category->orderBy('name', asc)->get(); return view('dashboard/products')->with('products', $products)->with('categories', $categories)->with('deleted', 1); }
/** * Display the specified resource. * * @param int $productId * @param Requests\ShowingSamplingsRequest $request * @return \Illuminate\Http\Response */ public function show($productId, ShowingSamplingsRequest $request) { $product = Product::join('locations', 'locations.product_id', '=', 'products.id')->where('locations.user_id', $this->guard->user()->getKey())->findOrFail($productId); // Just to throw a failure if the product is not found $samplingsQueryBuilder = Sampling::query(); $samplingsQueryBuilder->join('sensors', 'samplings.sensor_id', '=', 'sensors.id'); $samplingsQueryBuilder->join('generic_sensors', 'sensors.generic_sensor_id', '=', 'generic_sensors.id'); $samplingsQueryBuilder->join('products', 'sensors.product_id', '=', 'products.id'); $samplingsQueryBuilder->where('products.id', $productId); $samplingsQueryBuilder->orderBy('samplings.created_at', 'desc'); $limit = $request->has('limit') && $request->limit < 1000 ? $request->limit : 1000; if ($request->generic_sensor_id) { $samplingsQueryBuilder->where('generic_sensors.id', $request->generic_sensor_id); } $timeFiltersApplied = $this->filterResultsInTime($samplingsQueryBuilder, $request, $product); if (!$timeFiltersApplied) { $samplingsQueryBuilder->whereDate('samplings.created_at', '=', Carbon::today()->toDateString()); } $samplingsQueryBuilder->take($limit); // if ($timeFiltersApplied && array_has(["week", "month", "year"], $request->timeFilter)) { // return $samplingsQueryBuilder->selectRaw(" // samplings.sensor_id, // max(samplings.sampled), // generic_sensors.id as generic_sensor_id, // min(samplings.created_at) // "); // } return $samplingsQueryBuilder->get(array('samplings.id', 'samplings.sensor_id', 'generic_sensors.id as generic_sensor_id', 'samplings.sampled', 'samplings.created_at')); }