Пример #1
0
 /**
  * @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();
             }
         }
     }
 }
Пример #2
0
 /**
  * @Post("/cart/test")
  */
 public function test(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, 'art' => $itemInShop->art_number, 'description' => mb_substr($itemInShop->description, 0, 200) . '...', 'pic' => $itemInShop->attachment->url, '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) {
             $message->from('*****@*****.**', 'Test');
             $message->to('*****@*****.**')->subject('Test');
         });
     }
 }
Пример #3
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]);
 }
Пример #4
0
 /**
  * Remove the specified resource from storage.
  *
  * @Middleware("auth")
  */
 public function destroy($id)
 {
     ShopItems::find($id)->delete();
     return back();
 }