/**
  * @POST("/uploading_data")
  * @param Request $request
  * @return \Illuminate\Http\RedirectResponse
  */
 public function uploading_data(Request $request)
 {
     $photos = $request->input('photos');
     $category_id = $request->input('category_id');
     if ($request->input('shop_id')) {
         $shop_id = $request->input('shop_id');
         $shop = Shops::find($shop_id);
         if ($shop && !$shop->canAddItem()) {
             return redirect()->route('shops.my');
         }
         foreach ($photos as $photo) {
             foreach ($photo as $item) {
                 $attachment = new Attachment();
                 $attachment->name = $item['aid'];
                 $attachment->path = $item['src_big'];
                 $attachment->url = $item['src_big'];
                 $attachment->save();
                 $shop_item = new ShopItems();
                 $shop_item->name = 'Название';
                 $shop_item->description = $item['text'];
                 $shop_item->shop_id = $shop_id;
                 $shop_item->category_id = $category_id;
                 if ($attachment) {
                     $shop_item->attachment()->associate($attachment);
                 }
                 $shop_item->save();
             }
         }
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param Request $request
  * @return Response
  */
 public function store(Request $request)
 {
     $cat_id = \DB::table('items_category')->insertGetId(array('name' => $request->input('name'), 'description' => $request->input('description')));
     \DB::table('categories_shops')->insert(array('shop_id' => $request->input('shop_id'), 'category_id' => $cat_id));
     $shops = Shops::where('user_id', \Auth::user()->id)->orderBy('id', 'desc')->paginate(5);
     return view('shops::index', compact('shops'));
 }
示例#3
0
 /**
  * @param $id
  * @return \Illuminate\Http\RedirectResponse
  */
 public function block($id)
 {
     $shop = Shops::find($id);
     $input = \Request::only('blocked')['blocked'];
     $shop->blocked = $input;
     $shop->update();
     return redirect()->route('admin.shops.index');
 }
示例#4
0
 /**
  * @param ShopRequest $request
  * @return \Illuminate\Http\RedirectResponse
  */
 public function storeShop(ShopRequest $request)
 {
     $attachment = ImageUploadFacade::attachmentUpload($request->file('attachment'), new Attachment(), 'shops');
     $shop = new Shops();
     $shop->capacity = $request->get('capacity');
     $shop->city_id = $request->get('city');
     $shop->paid_at = Carbon::now()->addMonth();
     $shopProfile = new ShopProfile();
     $shopProfile->fill($request->except('attachment'));
     $shopProfile->save();
     $shop->profile()->associate($shopProfile);
     if ($attachment) {
         $shop->attachment()->associate($attachment);
     }
     $page = $request->page;
     $shop->user_id = $request->user_id;
     $shop->save();
     return redirect($page);
 }
示例#5
0
 public function run()
 {
     $faker = Faker\Factory::create();
     DB::table('shops')->delete();
     foreach (range(1, 3) as $index) {
         $city_id = \App\Models\Cities::orderBy(DB::raw('RAND()'))->first()->id;
         $user_id = rand(1, 3);
         $profile_id = \ZaWeb\Shops\Models\ShopProfile::orderBy(DB::raw('RAND()'))->first()->id;
         $attachment_id = \App\Models\Attachment::orderBy(DB::raw('RAND()'))->first()->id;
         \ZaWeb\Shops\Models\Shops::create(['user_id' => $user_id, 'city_id' => $city_id, 'capacity' => 300, 'attachment_id' => $attachment_id, 'profile_id' => $profile_id, 'created_at' => date('Y-m-d G:i:s'), 'updated_at' => date('Y-m-d G:i:s')]);
     }
 }
示例#6
0
 /**
  * Send orders
  * @Post("/cart/send_order", as="order.send")
  */
 public function send(Request $request)
 {
     $client = $request->user;
     $cart = $request->cart;
     $totalSum = 0;
     foreach ($cart as $item) {
         $itemInShop = ShopItems::find($item['_id']);
         $totalSum += $itemInShop->price * $item['_quantity'];
         $items[$item['_data']['partner']][] = ['id' => $itemInShop->id, 'name' => $itemInShop->name, 'price' => $itemInShop->price, 'quantity' => $item['_quantity']];
     }
     foreach ($items as $id => $positions) {
         $data = ['items' => $positions, 'client' => $client, 'totalSum' => $totalSum];
         $shop = Shops::find($id);
         \Mail::send('shops::emails.order', $data, function ($message) use($shop) {
             $message->from('*****@*****.**', 'Новый заказ');
             $message->to($shop->profile->email)->subject('Новый заказ');
         });
     }
 }
示例#7
0
 /**
  * @POST("shops/get_photos", middleware="auth")
  * @param Request $request
  * @return \Illuminate\Http\RedirectResponse
  */
 public function getPhotos(Request $request)
 {
     if ($request->s_id) {
         $shop_id = $request->s_id;
         \Session::put('shop_id', $shop_id);
     } else {
         $s_id = \Session::get('shop_id');
         $shop = Shops::find($s_id);
         if ($shop && !$shop->canAddItem()) {
             return redirect()->route('shops.my');
         }
         $file = ImageUploadFacade::attachmentUpload($request->file("file"), new Attachment(), 'shop_items');
         $item = new ShopItems();
         $item->name = 'Название';
         $item->description = 'Описание';
         $item->shop_id = $s_id;
         if ($file) {
             $item->attachment()->associate($file);
         }
         $item->save();
     }
     //return redirect()->route('shops.show', ['id'=>$request->id]);
 }
 /**
  * @param Request $request
  * @return \Illuminate\View\View
  */
 public function filter(Request $request)
 {
     $shops = Shops::where('category_id', $request->input('id'))->where('blocked', 0)->where('paid_at', '>=', new \DateTime('today'))->orderBy('id', 'desc')->paginate(5);
     return view('shops::index', compact('shops'))->with('category', $request->input('id'));
 }
示例#9
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  * @Middleware("auth")
  */
 public function show($id)
 {
     $shops = Shops::with('items')->find($id);
     return view('shops::shopitems.index', compact('shops'));
 }