public function edit($id) { $product = Product::find($id); $productTypes = ProductType::listSelect(); $units = Unit::orderBy('id', 'desc')->lists('name', 'id'); return view('products.edit', compact('product', 'productTypes', 'units')); }
/** * Run the database seeds. * * @return void */ public function run() { $securityType = ProductType::create(['name' => 'Security', 'slug' => 'security', 'description' => '<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec et quam commodo, pulvinar felis sed, dictum leo. Donec justo quam, cursus at iaculis sed, vulputate eget ex. Duis tincidunt purus ac turpis gravida sodales sed at sem. Curabitur laoreet lectus at nibh tincidunt rhoncus. Vestibulum non felis vel orci tempus interdum. Ut tempor auctor massa, in mattis orci finibus in. Sed sollicitudin feugiat nisl, suscipit bibendum felis cursus accumsan. Nulla sed nisi nec purus fermentum hendrerit sit amet a dolor. Phasellus congue facilisis sem, ac scelerisque massa. Nulla eu elit non lacus pretium vestibulum. In lorem dui, rhoncus eget facilisis eget, vestibulum eu dolor. Curabitur quis ligula feugiat, imperdiet lacus et, fringilla leo. Cras aliquet faucibus augue.</p>' . '<p>Phasellus turpis ipsum, porttitor sit amet lacinia et, mattis in arcu. Nullam pellentesque tempor leo, vel varius justo fringilla ac. Vestibulum nec euismod sem, id euismod enim. Etiam nec mattis orci, et blandit elit. Aenean bibendum purus non odio ornare, eget tempus turpis accumsan. Donec lorem magna, facilisis quis dignissim sit amet, vehicula quis neque. Donec sem sem, venenatis quis rutrum id, maximus at lectus. Phasellus molestie dignissim quam, id hendrerit mi volutpat a. Etiam venenatis vulputate ex nec egestas. Vestibulum scelerisque interdum metus, vel ullamcorper leo ultrices id. Nulla tincidunt condimentum eros eget placerat. Etiam tellus tortor, molestie hendrerit pulvinar non, aliquam eget nisl. Sed pulvinar ultricies metus ut ullamcorper.</p>']); $phoenixDoor = Product::create(['name' => 'Phoenix', 'type_id' => $securityType->id, 'description' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec non bibendum lacus, accumsan finibus elit. Integer malesuada urna nec bibendum consequat. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Etiam at tortor lorem. Morbi congue dolor at eros maximus laoreet. Maecenas dictum posuere sodales. Etiam']); $CyclopsDoor = Product::create(['name' => 'Cyclops', 'type_id' => $securityType->id, 'description' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec non bibendum lacus, accumsan finibus elit. Integer malesuada urna nec bibendum consequat. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Etiam at tortor lorem. Morbi congue dolor at eros maximus laoreet. Maecenas dictum posuere sodales. Etiam']); $WolverineDoor = Product::create(['name' => 'Wolverine', 'type_id' => $securityType->id, 'description' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec non bibendum lacus, accumsan finibus elit. Integer malesuada urna nec bibendum consequat. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Etiam at tortor lorem. Morbi congue dolor at eros maximus laoreet. Maecenas dictum posuere sodales. Etiam']); $phoenixImage = ProductImage::create(['file_name' => 'images/door.jpg', 'product_id' => $phoenixDoor->id]); }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { $product = Product::find($id); $product->name = $request->name; $product->desc = $request->desc; $product->productType()->associate(ProductType::find($request->productTypeId)); $product->save(); return $product; }
public function getType($slug) { $type = ProductType::where(['slug' => $slug])->first(); $gallery = array(); foreach ($type->products as $p) { $gallery[] = $p->gallery; } return view('product/type', ['page_title' => $type->name, 'productType' => $type, 'GalleryMatrix' => $gallery]); }
public function productTypes() { echo '<pre>'; $arr = ProductType::all(); //print_r($arr); foreach ($arr as $t) { $prod = $t->products->toArray(); print_r($prod); } }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy(Request $request, $id) { $response = ProductType::deleteByCondition($id); if ($request->ajax()) { return $response; } if ($response['status']) { flash()->success(trans('product_type.label.name'), $response['message']); } else { flash()->success(trans('product_type.label.name'), $response['message']); } return redirect('/product-types'); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { ProductType::destroy($id); }
/** * Execute the command. * * @param ProductTypeRepository $types * @return ProductType */ public function handle(ProductTypeRepository $types) { $type = ProductType::register($this->description); $types->save($type); return $type; }
public function anyTonDauThang(Request $request){ if($request->has('input-sort')){ $arr_sort = $request->input('input-sort'); $arr_sort =(array) json_decode($arr_sort); }elseif( session('sort_filter_product_ton_dau_thang.arr_sort') !== null){ $arr_sort = session('sort_filter_product_ton_dau_thang.arr_sort'); }else{ $arr_sort=array(); } session('sort_filter_product_ton_dau_thang.arr_sort', $arr_sort); $list_month = ReceiptMonth::select('month','year') ->distinct()->where('month','>',0) ->orderBy('year','ASC') ->orderBy('month','ASC') ->get()->toArray(); if($request->has('input-filter')){ $arr_filter = $request->input('input-filter'); }elseif( session('sort_filter_product_ton_dau_thang.arr_filter') !== null ){ $arr_filter = session('sort_filter_product_ton_dau_thang.arr_filter'); }else{ $arr_filter=[ 'sku'=>'', 'like_name'=>'', 'name'=>'', 'company_id'=>'', 'oum_id'=>'' ]; if(count($list_month)){ $arr_filter['month'] = $list_month[0]['month'].'-'.$list_month[0]['year']; } } session(['sort_filter_product_ton_dau_thang.arr_sort'=>$arr_sort]); session(['sort_filter_product_ton_dau_thang.arr_filter'=> $arr_filter]); $list_all_product = Product::select('sku','name')->orderBy('sku')->get()->toArray(); $list_month = array(); //Init array $distributes = array(); $oums = array(); $producttypes = array(); $list_sku = array(); //Get value array $distributes = Company::getDistributeList()->get()->toArray(); $oums = Oum::orderBy('name')->get()->toArray(); $producttypes = ProductType::get()->toArray(); $list_all_product = Product::select('sku','name')->orderBy('sku')->get()->toArray(); $list_product = TonDauThang::select( 'products.id', 'products.name', 'products.sku', 'ton_dau_thangs.quantity', 'ton_dau_thangs.month', 'ton_dau_thangs.year', 'm_products.oum_id', 'm_products.specification', 'm_products.origin_price', 'companies.name as company_name', 'oums.name as oum_name' ) ->addSelect(DB::raw('product_stocks.in_stock/m_products.specification as real_in_stock')) ->leftJoin('m_products','m_products.id','=','ton_dau_thangs.m_product_id') ->leftJoin('products','products.id','=','m_products.product_id') ->leftJoin('oums','oums.id','=','m_products.oum_id') ->leftJoin('companies','companies.id','=','m_products.company_id') ->leftJoin('product_stocks','m_products.id','=','product_stocks.m_product_id') ->groupBy('products.id','m_products.company_id','m_products.oum_id','m_products.specification','m_products.origin_price') ->where('ton_dau_thangs.quantity','>',0); foreach ($arr_filter as $key => $value) { if($value!=''){ if($arr_filter['sku']!=''){ $list_product->where('products.sku',$arr_filter['sku']); } if($key == 'like_name'){ $list_product->where('products.name','LIKE',"%".$arr_filter['like_name']."%"); $arr_filter['name']=''; } if($key == 'name' && $arr_filter['name']!=''){ $list_product->where('products.name',$arr_filter['name']); } if($key == 'company_id'){ $list_product->where('m_products.company_id',$arr_filter['company_id']); } if($key == 'status'){ $list_product->where('products.status',$arr_filter['status']); } if($key == 'oum_id'){ $list_product->where('m_products.oum_id',$arr_filter['oum_id']); } if($key == 'month' && $arr_filter['month'] !=''){ $month_year = explode('-',$arr_filter['month']); $list_product->where('ton_dau_thangs.month','=',$month_year[0]) ->where('ton_dau_thangs.year','=',$month_year[1]); } } } foreach ($arr_sort as $key => $value) { if($key=='company_id'){ $list_product = $list_product->orderBy('companies.name',$value); }elseif($key=='oum_id'){ $list_product = $list_product->orderBy('oums.name',$value); }elseif($key=='id'){ $list_product = $list_product->orderBy('products.id',$value); }elseif($key=='specification'){ $list_product = $list_product->orderBy('m_products.specification',$value); }elseif($key=='quantity'){ $list_product = $list_product->orderBy('ton_dau_thangs.quantity',$value); }else{ $list_product = $list_product->orderBy($key,$value); } } $list_month = ReceiptMonth::select('month','year') ->distinct()->where('month','>',0) ->orderBy('year','ASC') ->orderBy('month','ASC') ->get()->toArray(); $list_product = $list_product->orderBy('products.id','asc'); \Cache::put('list_product'.\Auth::user()->id, $list_product->get()->toArray(), 30); $sum_invest = 0; foreach ($list_product->get()->toArray() as $key => $value) { $sum_invest += $value['origin_price'] * $value['quantity']; } $list_product = $list_product->paginate(100); $this->layout->content=view('product.list-ton-dau-thang', [ 'distributes' => $distributes, 'oums' => $oums, 'producttypes' => $producttypes, 'list_product' => $list_product, 'list_all_product' => $list_all_product, 'arr_sort' => $arr_sort, 'arr_filter' => $arr_filter, 'sum_invest' => $sum_invest, 'list_month' => $list_month ]); }
public function anyEntry(Request $request,$id=null) { \DB::enableQueryLog(); if(isset($id) && $id!=null){ $id_purchaseorder = $id; $purchaseorder = Purchaseorder::find($id_purchaseorder); if($purchaseorder != null){ session(['current_purchaseorder' => $purchaseorder['id']]); }else{ return redirect('purchaseorders'); } }else{ $id_purchaseorder = session('current_purchaseorder') !== null ? session('current_purchaseorder') : 0; if($id_purchaseorder){ $purchaseorder = Purchaseorder::find($id_purchaseorder); session(['current_purchaseorder' => $purchaseorder['id']]); }else{ $purchaseorder = Purchaseorder::get()->last(); if($purchaseorder){ session(['current_purchaseorder' => $purchaseorder['id']]); }else{ $purchaseorder = new Purchaseorder; $purchaseorder->date = date("Y-m-d H:i:s"); $purchaseorder->created_by = \Auth::user()->id; $purchaseorder->save(); session(['current_purchaseorder' => $purchaseorder->id]); Log::create_log(\Auth::user()->id,'App\Purchaseorder','Tạo mới đơn mua hàng số '.$purchaseorder->id); session(['current_purchaseorder' => $purchaseorder->id]); } } } $address = Address::where('module_id','=',$purchaseorder->id) ->where('module_type','=','App\Purchaseorder')->first(); $address_province = isset($address->province_id)?$address->province_id:0; $country_province = Province::addSelect('provinces.name as province_name') ->where('provinces.id','=',$address_province) ->addSelect('countries.name as country_name') ->leftJoin('countries','countries.id','=','provinces.country_id') ->first(); if($country_province){ $country_province->toArray(); $purchaseorder['province_name'] = $country_province['province_name']; $purchaseorder['country_name'] = $country_province['country_name']; }else{ $purchaseorder['province_name'] = ''; $purchaseorder['country_name'] = ''; } if($address){ $address = $address->toArray(); }else{ $address = array(); } $purchaseorder = $purchaseorder->toArray(); //Init array $distributes = array(); $oums = array(); $users = array(); $countries = array(); $list_product = array(); $producttypes = array(); //Get value array $distributes = Company::getDistributeList()->with('address')->get()->toArray(); $oums = Oum::orderBy('name')->get()->toArray(); $users = User::get(); $countries = Country::with('provinces')->get()->toArray(); $producttypes = ProductType::get()->toArray(); $arr_product = MProduct::where('module_type','=','App\Purchaseorder') ->where('module_id','=',$purchaseorder['id']) ->lists('product_id'); Session::forget('product_of_po'.session('current_purchaseorder')); foreach ($arr_product as $key => $value) { Session::put('product_of_po'.session('current_purchaseorder').".".$value , $value); } $view_list_product = self::getListProduct(); $arr_create = Purchaseorder::select('users.name','purchaseorders.created_at') ->leftJoin('users','users.id','=','purchaseorders.created_by') ->where('purchaseorders.id','=',$purchaseorder['id']) ->get()->first()->toArray(); $arr_update = Purchaseorder::select('users.name','purchaseorders.updated_at') ->leftJoin('users','users.id','=','purchaseorders.updated_by') ->where('purchaseorders.id','=',$purchaseorder['id']) ->get()->first()->toArray(); $this->layout->arr_create = $arr_create; $this->layout->arr_update = $arr_update; $this->layout->content=view('purchaseorder.entry',[ 'distributes'=>$distributes, 'users'=>$users, 'countries'=>$countries, 'purchaseorder'=>$purchaseorder, 'address'=>$address, 'oums'=>$oums, 'producttypes'=>$producttypes, 'view_list_product'=>$view_list_product ]); }
/** * Show the application dashboard. * * @return \Illuminate\Http\Response */ public function index() { $types = ProductType::with('Products')->get(); return view('home', array('types' => $types)); }
function it_can_be_registered() { $type = ProductType::register('Book'); \PHPUnit_Framework_Assert::assertEquals('Book', $type->description); }
public function getDeleteProducttype($id) { $arr_return = array( "status"=>"error" ); $producttype = ProductType::find($id); if($producttype->delete()){ $arr_return['status'] = 'success'; }else{ $arr_return['message']= "Delete fail"; } return $arr_return; }
/** * Returns a collection with all product types. * * @return Collection */ public function all() { return ProductType::orderBy('description')->get(); }
/** * Show the products of a selected type. * * @return \Illuminate\Http\Response */ public function showProductsByType($id) { $type = ProductType::with('Products')->find($id); return view('showProductsByType', array('type' => $type)); }
/** * Run the database seeds. * * @return void */ public function run() { ProductType::create(['name' => 'ปลอกหางปลา']); ProductType::create(['name' => 'หางปลา']); ProductType::create(['name' => 'เทป']); }