예제 #1
0
 public function item($id = 0)
 {
     $item = Items::find($id);
     if ($item['obj']) {
         $obj = json_decode($item['obj'], true);
         $item['obj'] = $obj;
         if (!isset($obj['images'])) {
             $item->images = [];
         } else {
             $item->images = $obj['images'];
         }
     }
     $catalog_banner = UIComponents::where('name', '=', 'catalog-banner')->get()->first();
     $catalog_banner_arr = [];
     if (isset($catalog_banner) && isset($catalog_banner->obj)) {
         $obj = json_decode($catalog_banner->obj);
         if (isset($obj->images)) {
             $catalog_banner_arr['images'] = $obj->images;
         }
         if (isset($obj->html)) {
             $catalog_banner_arr['html'] = $obj->html;
         }
     }
     if (isset($item['obj']['Версия/Модификация']) && trim($item['obj']['Версия/Модификация']) != '') {
         $item['name'] = "{$item['obj']['type_auto'][0]['children'][0]['text']}" . " {$item['obj']['type_auto'][0]['children'][0]['children'][0]['text']}" . " {$item['obj']['Версия/Модификация']}" . " {$item['obj']['God_vypuska'][0]['text']}";
     } else {
         $item['name'] = "{$item['obj']['type_auto'][0]['children'][0]['text']}" . " {$item['obj']['type_auto'][0]['children'][0]['children'][0]['text']}" . " {$item['obj']['God_vypuska'][0]['text']}";
     }
     return view('catalog/catalog/item', ['item' => $item, 'catalog_banner' => $catalog_banner_arr]);
 }
예제 #2
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Items::create(['item_name' => 'Venda 4 mts. 3M', 'item_description' => 'Venda de 4 metros por 5 cm. de largo', 'min_quantity' => '20', 'stock_quantity' => '35', 'profit_percentage' => '1', 'type' => '1', 'cost' => '43.56']);
     Items::create(['item_name' => 'Solución salina', 'item_description' => 'Splución salina intravenosa', 'min_quantity' => '50', 'stock_quantity' => '48', 'profit_percentage' => '2', 'type' => '1', 'cost' => '67.99']);
     Items::create(['item_name' => 'Equipo para Venoclisis', 'item_description' => 'Normogotero que está elaborado con diferentes tipos de plástico grado médico y que su característica principal es la de proporcionar un goteo comprendido entre 28 y 32 gotas por minuto.', 'min_quantity' => '10', 'stock_quantity' => '25', 'profit_percentage' => '3', 'type' => '1', 'cost' => '234.45']);
     Items::create(['item_name' => 'Sonda de Foley', 'item_description' => 'Los catéteres de Foley se fabrican en varios subtipos. Los catéteres Coudé (palabra francesa que significa acodado/en codo) tienen en la extremidad una curva de 45° para permitir un paso más fácil a través de una próstata agrandada.', 'min_quantity' => '20', 'stock_quantity' => '35', 'profit_percentage' => '1', 'type' => '1', 'cost' => '868.77']);
 }
 public function get_category($get_category_id, $get_subcategory_id, $search_term)
 {
     $sub_categories = Sub_category::all();
     $arr = array();
     if ($get_category_id == 0 && $get_subcategory_id == 0) {
         foreach ($sub_categories as $sub_category) {
             array_push($arr, $sub_category->id);
         }
     } else {
         if ($get_category_id != 0 && $get_subcategory_id == 0) {
             foreach ($sub_categories as $sub_category) {
                 if ($sub_category->categories_id == $get_category_id) {
                     array_push($arr, $sub_category->id);
                 }
             }
         } else {
             if ($get_category_id != 0 && $get_subcategory_id != 0) {
                 array_push($arr, $get_subcategory_id);
             }
         }
     }
     if ($search_term != null) {
         $items = Items::whereIn('sub_categories_id', $arr)->where('title', 'like', '%' . $search_term . '%')->paginate(12);
     } else {
         $items = Items::whereIn('sub_categories_id', $arr)->paginate(12);
     }
     return $items;
 }
예제 #4
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     //
     //        $name = Auth::user()->email;
     //        return view('dashboard');
     $user = Auth::user()->name;
     $userId = Auth::user()->id;
     $locateInDbUser = App\User::find($userId);
     $locateInDbItems = App\Items::find($userId);
     $locateInDbWatchlist = App\Watchlist::find($userId);
     $itemsWatched = DB::table('watchlists')->where('user_id', '=', $userId)->count();
     $itemsOwned = DB::table('items')->where('users_id', '=', $userId)->count();
     $benefit = $locateInDbUser->benefits;
     $auction_wins = $locateInDbUser->auction_wins;
     $itemsOnWatchlist = DB::table('watchlists')->where('user_id', '=', $userId)->get();
     if ($itemsOnWatchlist == []) {
         $queryWatchlist = '';
         return view('dashboard')->with('user', $user)->with('userId', $userId)->with('benefits', $benefit)->with('auction_wins', $auction_wins)->with('itemsWatched', $itemsWatched)->with('itemsOwned', $itemsOwned)->with('itemsOnWatchlist', $itemsOnWatchlist)->with('queryWatchlist', $queryWatchlist);
     } else {
         $queryWatchlist = DB::table('items');
         foreach ($itemsOnWatchlist as $itemOnWatchlist) {
             $queryWatchlist->orWhere('id', '=', $itemOnWatchlist->item_id);
         }
         $queryWatchlist = $queryWatchlist->get();
         //        return $queryWatchlist;
         return view('dashboard')->with('user', $user)->with('userId', $userId)->with('benefits', $benefit)->with('auction_wins', $auction_wins)->with('itemsWatched', $itemsWatched)->with('itemsOwned', $itemsOwned)->with('itemsOnWatchlist', $itemsOnWatchlist)->with('queryWatchlist', $queryWatchlist);
     }
 }
예제 #5
0
파일: Items.php 프로젝트: sislex/cat
 static function modifiedData($input)
 {
     $item = Items::where('id', '=', $input['id'])->get()->first();
     $text = '';
     if ($item) {
         $text = $item->text;
     }
     if ($input && isset($input['obj']) && $input['obj']) {
         $obj = json_decode($input['obj'], true);
         $mark = isset($obj['type_auto'][0]['children'][0]['text']) ? $obj['type_auto'][0]['children'][0]['text'] : '';
         $model = isset($obj['type_auto'][0]['children'][0]['children'][0]['text']) ? $obj['type_auto'][0]['children'][0]['children'][0]['text'] : '';
         $god = isset($obj['God_vypuska'][0]['text']) ? $obj['God_vypuska'][0]['text'] : '' . 'г.';
         $toplivo = isset($obj['Тип двигателя'][0]['text']) ? $obj['Тип двигателя'][0]['text'] : '';
         if (isset($input['price'])) {
             $input['price'] = intval($input['price']);
             $price = "Цена {$input['price']}\$";
         } else {
             $price = '';
         }
         $price = isset($input['price']) ? "Цена {$input['price']}\$" : '';
         if (isset($input['title']) && $input['title'] == '') {
             $input['title'] = "Купить {$mark} {$model} {$god} {$toplivo} {$price} в Минске Голденмоторс";
         }
         if (isset($input['description']) && $input['description'] == '') {
             $input['description'] = "Продажа в РБ {$mark} {$model} {$text}";
         }
         if (isset($input['keywords']) && $input['keywords'] == '') {
             $input['keywords'] = "{$mark} {$model}";
         }
     }
     return $input;
 }
예제 #6
0
 function checkout(DeliveryFormRequest $request)
 {
     if (isset($_COOKIE['basket'])) {
         $orders = $_COOKIE['basket'];
         $orders = json_decode($orders);
     } else {
         return redirect('/basket');
     }
     $ids = [];
     $amount = [];
     $total_cost = 0;
     $order_id = Orders::latest()->first();
     //получаем последний заказ
     empty($order_id) ? $order_id = 1 : ($order_id = $order_id->order_id + 1);
     //определяемся с новым заказом, увеличивая номер последнего заказа на 1
     foreach ($orders as $order) {
         $ids[] = $order->item_id;
         //создаем массив из id заказанных товаров
         $amount[$order->item_id] = $order->amount;
         //создаем массив с количеством каждого товара ['id товара'=>'количество товара']
     }
     $items = Items::whereIn('id', $ids)->get();
     foreach ($items as $item) {
         $orders = Orders::create(['item_id' => $item->id, 'price' => $item->price, 'order_id' => $order_id, 'amount' => $amount[$item->id], 'name' => $request->name, 'address' => $request->address, 'phone' => $request->phone]);
         //сохраняем заказ в базу
         $total_cost = $total_cost + $item->price * $amount[$item->id];
     }
     setcookie('basket', '');
     $orders = Orders::where('order_id', $orders->order_id)->get();
     return view('finish_order', ['orders' => $orders, 'total' => $total_cost]);
 }
예제 #7
0
 public function viewImages()
 {
     $imDets = Items::all();
     return view('pages/home1')->with('imDets', $imDets);
     //        return $imDets;
     //        //return 'hello';
     //        $imDets = 'hello';
     //        return view('pages/home')->with('imDets',$imDets);
 }
예제 #8
0
 public function index($id = 0)
 {
     $categories = Categories::all();
     $categories = $categories->sortBy('sort_id');
     $item = Items::find($id);
     $comments = Comments::where('items_id', '=', $id)->get();
     $data = ['categories' => $categories, 'item' => $item, 'id' => $item->categories_id, 'comments' => $comments];
     return view('items.index', $data);
 }
예제 #9
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $item = Items::find($id);
     if ($item) {
         return view('item.addImage', compact('item'));
     } else {
         return redirect()->action('ItemsController@index')->with('error', 'El producto solicitado no existe');
     }
 }
 /**
  * Vérification des données utilisateurs avant la création de l'enchère
  *
  * @param Request $request
  * @param int $item_id Identifiant de l'item
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function add(Request $request, $item_id)
 {
     // Après quelques vérifications, l'utilisateur saura s'il a le droit d'enchérir ou non
     $denied = false;
     // On récupère l'ID du formulaire (permettra de savoir à quel formulaire une erreur s'est produite)
     $form_id = $request->input('_form_id', 'default');
     // Si l'utilisateur a supprimé le champ (gg), on essaye de récupérer l'ID dans l'URL
     if ($form_id === null && preg_match('/\\/items/', URL::previous())) {
         $url_items = explode('/', $request->getPathInfo());
         $form_id = 'form_' . array_pop($url_items);
     }
     // Les messages d'erreurs seront désormais spécifiques à un formulaire, et pas tous
     $this->validatesRequestErrorBag = $form_id;
     // Permettra de savoir dans quel formulaire s'est produite l'erreur
     $request->session()->flash('errorBag', $this->validatesRequestErrorBag);
     // On check si l'item existe bien dans la BBD ('Ivre, il enchérit une vente qui n'existe pas, la suite va vous surprendre !)
     $item = Items::get()->where('id', $item_id)->first();
     $min_price = $item->getPrice() + 1;
     // L'enchère n'existe pas
     if ($item === null) {
         $denied = true;
         $request->session()->flash('message', 'danger|Cette enchère n\'existe pas');
         return redirect(route('items'));
     }
     // L'enchère existe, donc on fait quelques tests dessus
     if ($item !== null) {
         // La vente n'a pas encore commencé
         if (strtotime($item->date_end) - time() < 0) {
             $denied = true;
             $request->session()->flash('message', 'danger|L\'enchère n\'a même pas commencé, calmez-vous...');
             // La vente est terminé
         } elseif (strtotime($item->date_start) - time() > 0) {
             $denied = true;
             $request->session()->flash('message', 'danger|L\'enchère est terminée !');
         }
         // L'utilisateur a atteint le nombre maximum de renchère sur cette annonce
         if ($item->getUserCantBid()) {
             $denied = true;
             $request->session()->flash('message', 'danger|Vous avez dépassé les ' . MAX_BID_PER_SALE . ' propositions d\'enchères maximales !');
         }
     }
     // Le vendeur ne peut pas enchérir sa propre annonce...
     if ($item->isSeller()) {
         $denied = true;
         $request->session()->flash('message', 'danger|Il n\'est pas possible d\'enchérir votre annonce..');
     }
     // Pour une quelconque raison, l'utilisateur n'a pas pu enchérir
     if ($denied) {
         return redirect(route('items'));
     }
     // Le prix rentré doit être supérieur à la valeur minimale de l'enchère
     $this->validate($request, ['price' => 'required|numeric|min:' . $min_price], ['price.min' => 'Le prix doit être supérieur à :min €.']);
     return $this->create($request, $item_id);
 }
예제 #11
0
 public function add(Request $request)
 {
     $validator = $this->validator($request->all());
     if ($validator->fails()) {
         $this->throwValidationException($request, $validator);
     }
     $item = Items::find($request->items_id);
     $item->count_comments++;
     $item->save();
     $this->create($request->all());
     return redirect('items/' . $request->items_id);
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     //
     $user = Auth::user()->name;
     $userId = Auth::user()->id;
     $locateInDbUser = App\User::find($userId);
     $locateInDbItems = App\Items::find($userId);
     $locateInDbWatchlist = App\Watchlist::find($userId);
     $itemsWatched = DB::table('watchlists')->where('user_id', '=', $userId)->count();
     $itemsSelect = DB::table('items')->where('betting_status', '=', 1)->where('users_id', '=', $userId)->orderBy('id', 'asc')->lists('item_name');
     $itemsOwned = DB::table('items')->where('users_id', '=', $userId)->count();
     $benefit = $locateInDbUser->benefits;
     $auction_wins = $locateInDbUser->auction_wins;
     return view('retrieveOffer')->with('user', $user)->with('userId', $userId)->with('benefits', $benefit)->with('auction_wins', $auction_wins)->with('itemsWatched', $itemsWatched)->with('itemsOwned', $itemsOwned)->with('itemsSelect', $itemsSelect);
 }
예제 #13
0
 public function index($id = 0)
 {
     //get rundom category
     if ($id == 0) {
         $category = Categories::where('parent_id', '!=', 0)->orderBy(DB::raw('RAND()'))->take(1)->get();
         $id = $category[0]->id;
     }
     //get all categories for menu
     $categories = Categories::all();
     $categories = $categories->sortBy('sort_id');
     //get categories for slider
     $sliders = Categories::where('parent_id', '!=', 0)->orderBy(DB::raw('RAND()'))->take(3)->get();
     //get items
     $items = Items::where('categories_id', '=', $id)->get();
     $data = ['categories' => $categories, 'items' => $items, 'id' => $id, 'sliders' => $sliders];
     return view('categories.index', $data);
 }
예제 #14
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     if (States::isProtected($id)) {
         return $this->error("This item is protected");
     }
     if (sizeof(States::all()) <= 2) {
         return $this->error("Do you really want to delete all States? In which state are you?!");
     }
     if (Items::hasStatus($id) || Persons::hasStatus($id)) {
         return $this->error("Do you really want to delete all States? In which state are you?!");
     }
     $data = States::find($id);
     if ($data) {
         $data->delete();
         return $this->success($data);
     } else {
         return $this->error("Item doesn't exist");
     }
 }
예제 #15
0
 /**
  * Update details for the item.
  *
  * @author Sinthujan G.
  * @return mixed    Redirects to view with Error or Success messages.
  */
 public function upPrices()
 {
     $dets = array('itName' => Request::input('iName'), 'itDescrip' => Request::input('iDescrip'), 'itPrice' => Request::input('iPrice'));
     $rules = array('itName' => 'required', 'itDescrip' => 'required', 'itPrice' => 'required|numeric');
     $messages = array('itName.required' => 'The item name is required.', 'itDescrip.required' => 'The item description is required.', 'itPrice.required' => 'The item price is required.', 'itPrice.numeric' => 'The item price must be numeric.');
     // doing the validation, passing post data, rules and the messages
     $validator = Validator::make($dets, $rules, $messages);
     if ($validator->fails()) {
         // send back to the page with the input data and errors
         return Redirect::to('aitem')->withInput()->withErrors($validator);
     } else {
         $itID = DB::table('items')->select('itID')->where('itName', '=', $dets['itName'])->first();
         $chkList = DB::table('itemorders')->join('orders', 'orders.ordID', '=', 'itemorders.ordID')->join('users', 'orders.custID', '=', 'users.email')->where('itemorders.itID', '=', $itID->itID)->where('orders.status', '=', 'Ongoing')->count();
         if ($chkList > 0) {
             return Redirect::to('aitem')->withInput()->withErrors("This item is currently in order. Please update after the order has been completed.");
         } else {
             $res = Items::where('itName', '=', $dets['itName']);
             $res->update($dets);
         }
         if (!$res) {
             App::abort(500, 'Some Error');
         }
         return Redirect::to('aitem')->with('success', true)->with('message', 'Item sucessfully updated');
     }
 }
예제 #16
0
 function search_items(Request $request)
 {
     $s_item = $request->search_item;
     $items = Items::where('title', 'like', '%' . $s_item . '%')->paginate(10);
     return view('manage-items', ['items' => $items]);
 }
예제 #17
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $data = Persons::find($id);
     if ($data) {
         if (Items::hasUser($data->id)->first()) {
             return $this->error("there is still an item allocated to his person");
         } else {
             $data->delete();
             return $this->success($data);
         }
     } else {
         return $this->error("No item with this id");
     }
 }
 /**
  * Permet de récupérer plus simplement les annonces qui viennent de se terminer
  *
  * @return mixed
  */
 public function getItemsToHandle()
 {
     return Items::where('date_end', '<=', date('Y-m-d'))->with('user', 'bids')->get();
 }
예제 #19
0
 public function ShowSubCategoryItems($id)
 {
     $data['slider'] = Slide::orderBy('created_at', 'asc')->get();
     $data['sideslider'] = SideSlider::orderBy('created_at', 'asc')->get();
     $data['partner'] = Partner::orderBy('created_at', 'asc')->get();
     $data['category'] = Category::with('SubCategory')->orderBy('created_at', 'asc')->get();
     $data['categoryex'] = Category::findOrFail($id);
     $data['categoryex'] = Category::with('SubCategory')->findOrFail($id);
     $data['subcategory'] = SubCategory::findOrFail($id);
     $data['item'] = Items::where('subcategory_id', $id)->orderBy('created_at', 'asc')->paginate(12);
     return view('site.category-item-list', $data);
 }
예제 #20
0
 public function show($id)
 {
     $items = Items::find($id);
     $parameters = $items->parameters;
     $count = $parameters->count();
     $res = collect([]);
     for ($i = 0; $i < $count; $i++) {
         $value = Items_parameters::where('items_id', $items->id)->get()[$i]->value;
         $res->push(collect(['title' => $parameters[$i]->title, 'unit' => $parameters[$i]->unit, 'value' => $value]));
     }
     $res = $res->toArray();
     if ($items->preview != "") {
         $images = explode(';', $items->preview);
     } else {
         $images = null;
     }
     $categories = "";
     $categories = DB::table('sub_categories')->select('title')->where('id', $items->sub_categories_id)->get();
     if (!empty($categories)) {
         $categories = $categories[0]->title;
     } else {
         $categories = "non categories";
     }
     $main_categories = Category::all();
     return view('show-item', ['items' => $items, 'res' => $res, 'images' => $images, 'categories' => $categories, 'main_categories' => $main_categories]);
 }
예제 #21
0
 public function searchItemForm()
 {
     $itemToSearchName = Input::get('itemName');
     $itemToSearchSelect = Input::get('userChosen');
     $itemToSearchSelect2 = Input::get('categoryChosen');
     $user = Auth::user()->name;
     $userId = Auth::user()->id;
     //            $itemsToId=DB::table('items')
     //                ->where('item_name','=',$itemToOffer)
     //                ->where('users_id','=',$userId)
     //                ->first();
     $query = DB::table('items');
     $query->where('users_id', '<>', $userId);
     $query->where('betting_status', '=', 1);
     if ($itemToSearchSelect != 'Any user') {
         //                $query->where('user')
         $usersSelect = DB::table('users')->where('email', '=', $itemToSearchSelect)->first();
         $query->where('users_id', '=', $usersSelect->id);
     }
     if ($itemToSearchSelect2 != 'Any category') {
         //                $query->where('user')
         //            $catSelect=DB::table('categories')
         //                ->where('catname','=',$itemToSearchSelect2)
         //                ->first();
         $query->where('category1', '=', $itemToSearchSelect2);
     }
     if ($itemToSearchName != '') {
         $query->where('item_name', 'LIKE', '%' . $itemToSearchName . '%');
     }
     $rows = $query->get();
     if ($rows == []) {
         Session::flash('messageErrorDate', "No match, redefine your search terms");
         return redirect('searchItem');
     } else {
         $rows = $query->paginate(10);
         $user = Auth::user()->name;
         $userId = Auth::user()->id;
         $locateInDbUser = App\User::find($userId);
         $locateInDbItems = App\Items::find($userId);
         $locateInDbWatchlist = App\Watchlist::find($userId);
         $itemsWatched = DB::table('watchlists')->where('user_id', '=', $userId)->count();
         $usersTable = DB::table('users');
         $itemsOwned = DB::table('items')->where('users_id', '=', $userId)->count();
         $benefit = $locateInDbUser->benefits;
         $auction_wins = $locateInDbUser->auction_wins;
         Session::flash('messageOkSearch', "");
         return view('searchResults')->with('user', $user)->with('userId', $userId)->with('benefits', $benefit)->with('auction_wins', $auction_wins)->with('itemsWatched', $itemsWatched)->with('itemsOwned', $itemsOwned)->with('rowsSearch', $rows)->with('usersTable', $usersTable);
     }
     //        return $rows;
 }
예제 #22
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $data = Items::find($id);
     if ($data) {
         $data->delete();
         return response()->json($data);
     } else {
         return $this->error("No item with this id");
     }
 }
 /**
  * Insère un nouvel item dans la BDD
  *
  * @param Request $request
  * @return bool|mixed
  */
 public function create(Request $request)
 {
     $datas = $request->all();
     $manager = new ImageManager(['driver' => 'imagick']);
     // Création de l'Item
     $item = new Items();
     $item->user_id = Auth::user()->id;
     $item->category_id = Categories::where('slug', $datas['category'])->value('id');
     $item->name = trim($datas['name']);
     $item->description = trim($datas['description']);
     $item->price = $datas['price'];
     $item->date_start = $datas['date_start'];
     $item->date_end = $datas['date_end'];
     // Récupération de la photo envoyée par l'utilisateur
     $file = $request->file('photo');
     $filename = str_limit(str_replace(['/', '\\'], '', $file->getClientOriginalName()), 30) . str_random();
     $filename_thumb = $filename . '_thumb';
     // Sauvegarde de la photo
     $file->move(public_path('upload'), $filename . '.' . $file->getClientOriginalExtension());
     // On sauvegarde un lien relatif pour le lien de la photo, pour éviter un bordel monstre lors d'un
     // changement de nom de domaine.
     $item->photo = 'upload/' . $filename . '.jpg';
     // Là on peut utiliser le chemin absolu de l'image (/home/..../image.jpg)
     $filename = public_path('upload') . '/' . $filename;
     $filename_thumb = public_path('upload') . '/' . $filename_thumb;
     // Active l'entrelacement sur la photo envoyée par l'utilisateur et réduit la qualité
     $manager->make($filename . '.' . $file->getClientOriginalExtension())->interlace(true)->save($filename . '.jpg', 80);
     // Si par exemple l'utilisateur a envoyé un .png (ou un .JpG), alors on supprime l'image,
     // puisqu'on a déjà sauvegardé une version en .jpg
     if ($file->getClientOriginalExtension() !== 'jpg') {
         unlink($filename . '.' . $file->getClientOriginalExtension());
     }
     // Création de la miniature, de taille 300px * ratio px.
     $manager->make($filename . '.jpg')->resize(300, null, function ($constraint) {
         $constraint->aspectRatio();
     })->interlace(true)->save($filename_thumb . '.jpg');
     // Si on a bien réussi à sauvegarder l'Item, on renvoie l'id, pour une redirection sur la page de l'Item
     if ($item->save()) {
         return $item->id;
     }
     // Sinon il y a eu un problème. :< :< :<
     return false;
 }
예제 #24
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function delete($id)
 {
     $item = Items::find($id);
     $item->delete();
     return \Redirect::action('Admin\\ItemsController@index');
 }
예제 #25
0
 public function FinalItembet($idItem)
 {
     $user = Auth::user()->name;
     $userId = Auth::user()->id;
     $locateInDbUser = App\User::find($userId);
     $locateInDbItems = App\Items::find($userId);
     $locateInDbWatchlist = App\Watchlist::find($userId);
     $itemId = explode('X', $idItem);
     $itemId = intval($itemId[0]);
     $itemsWatched = DB::table('watchlists')->where('user_id', '=', $userId)->count();
     $itemsName = DB::table('items')->where('id', '=', $itemId)->value('item_name');
     $itemsDescription = DB::table('items')->where('id', '=', $itemId)->value('description');
     $itemsMin = DB::table('items')->where('id', '=', $itemId)->value('minimalPrice');
     $itemsOwned = DB::table('items')->where('users_id', '=', $userId)->count();
     $benefit = $locateInDbUser->benefits;
     $auction_wins = $locateInDbUser->auction_wins;
     //
     return view('FinalItembet')->with('user', $user)->with('userId', $userId)->with('benefits', $benefit)->with('auction_wins', $auction_wins)->with('itemsWatched', $itemsWatched)->with('itemsOwned', $itemsOwned)->with('itemsDescription', $itemsDescription)->with('itemsMin', $itemsMin)->with('itemId', $itemId)->with('itemsName', $itemsName);
 }
예제 #26
0
 public function destroy(Request $request, $id)
 {
     //ELIMINA PRODUCTO
     $item = Items::find($id);
     if ($item->delete()) {
         //SE REGISTRA LA ACTIVIDAD EN LA BITACORA
         $this->binnacle("ELIMINÓ PRODUCTO", $request);
     }
     return redirect()->action('ItemsController@index')->with('message', 'El producto se eliminó correctamente');
 }
예제 #27
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $item = Items::findOrFail($id);
     try {
         File::delete(public_path() . '/uploads/item/' . $item->main_image);
         $item->destroy($id);
     } catch (Exception $e) {
         App::abort(404);
     }
     return Redirect::route('admin.item.show');
 }
예제 #28
0
 public function deleteItem($id)
 {
     $item = Items::findOrFail($id);
     $item->delete();
     return redirect('/itemlist')->with('flash_notification.message', 'Successfully deleted your item.')->with('flash_notification.level', 'success');
 }
예제 #29
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     Items::destroy($id);
     return redirect('item');
 }
예제 #30
0
 public function edit($id)
 {
     $acquisition = Acquisitions::find($id);
     if ($acquisition) {
         $contacts = Contacts::type('PROVEEDOR')->orderBy('name')->get()->lists('name', 'id');
         $items = Items::orderBy('item_name')->lists('item_name', 'id');
         return view('acquisition.edit', compact('acquisition', 'contacts', 'items'));
     } else {
         return redirect()->action('AcquisitionsController@index')->with('error', 'La compra solicitada no existe');
     }
 }