示例#1
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     //
     $bomhead = Bomhead::findOrNew($id);
     $parentItem = Item::findOrFail($id);
     $bomitems = Bomitem::latest('created_at')->where('parent_item_id', $id)->with('parentitem')->get();
     return view('boms.edit', compact('bomhead', 'parentItem', 'bomitems'));
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id, Request $request)
 {
     $this->validate($request, ['id' => 'required']);
     $item = Item::findOrFail($id);
     $item->update($request->all());
     Session::flash('flash_message', 'Item successfully updated!');
     return redirect('item');
 }
 public function unlike($item, $userId)
 {
     $item = Item::findOrFail($item);
     if ($item->unlike($userId)) {
         event(new UserUnlikedAnItem($item));
         return 'You unliked an item.';
     }
     return 'There was a problem unliking a post.';
 }
 public function delete(Request $request)
 {
     $item = Item::findOrFail($request->id);
     $item->delete_stat = 1;
     $item->save();
     $itemid = $item->id;
     $employeeid = Auth::user()->id;
     $logs = ActivityLog::create(['employee_id' => $employeeid, 'activity' => 'Delete Item', 'table_affected' => 'item', 'primary_key' => $itemid, 'column_affected' => 'remove_stat']);
     return redirect()->route('erp_system.item.index')->withSuccess('Item deleted.');
 }
 public function postIndex()
 {
     $id = Input::get('id');
     //findOrFail is a method provided by Eloquent (in item model)
     $item = Item::findOrFail($id);
     if ($item->owner_id == Auth::user()->id) {
         //only mark it when the logged in user is the owner
         $item->mark();
     }
     return Redirect::route('home');
 }
示例#6
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update(Request $request, $id)
 {
     $item = Item::findOrFail($id);
     $item = $this->getRequestItem($request, $item);
     //// category object
     $category = new Category();
     $category->name = $request->get('category');
     $category->container_id = $request->get('container_id');
     $item = Item::persist($item, $category)->toArray();
     $item['category'] = $category->name;
     return $item;
 }
示例#7
0
 public function toggleDone($id)
 {
     $item = Item::findOrFail($id);
     if ($item->status == 0) {
         $item->status = 1;
         $item->update();
         return true;
     } else {
         $item->status = 0;
         $item->update();
         return true;
     }
     return false;
 }
示例#8
0
 /**
  * [markAsFavorite mark a podcast item as favorite]
  * @return array
  */
 public function markAsFavorite()
 {
     $result['status'] = 0;
     $result['message'] = 'Something went wrong, please try again';
     $itemId = trim(strip_tags(Request::get('itemId')));
     $item = DB::table('items')->select('user_id')->where('user_id', '=', Auth::user()->id)->where('id', '=', $itemId)->first();
     // if item with id exists in DB and is owned by the authenticated user
     if ($item) {
         $podcastItem = Item::findOrFail($itemId);
         $result['currentValue'] = !$podcastItem->is_mark_as_favorite;
         $podcastItem->is_mark_as_favorite = !$podcastItem->is_mark_as_favorite;
         // opposite of current value
         $podcastItem->save();
         $result['status'] = 1;
         $result['message'] = 'This item has been updated';
     }
     return $result;
 }
 public function getFiles(ItemRequest $request)
 {
     $item = Item::findOrFail($request->get('item_id'));
     $list = [];
     $size = 0;
     //        foreach ($item->items as $item) {
     //            $list[] = [
     //                'file' => $item->title,
     //                'path' => $item->path,
     //                'id' => $item->id,
     //            ];
     //        }
     foreach ($item->files()->get() as $file) {
         $size += $file->size;
         $list[] = ['file' => $file->filename, 'path' => "{$item->path}/{$file->filename}", 'size' => $this->formatBytes($file->size)];
     }
     return response()->json(['files' => $list, 'count' => count($list), 'size' => $this->formatBytes($size)]);
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $item = \App\Item::findOrFail($id);
     $item->delete();
     return 'The resource #' . $id . ' was deleted';
 }
示例#11
0
 /**
  * Update the specified resource in storage.
  *
  * @param  Request  $request
  * @param  int  $id
  * @return Response
  */
 public function update(ItemRequest $request, $id)
 {
     $item = Item::findOrFail($id);
     $item->update($request->all());
     $prices = Price::where('item_id', '=', $id)->orderBy('sellable')->get();
     foreach ($prices as $price) {
         if ($price->custom_price < $item->minimum_price) {
             $price->sellable = 0;
             $price->save();
         } else {
             $price->sellable = 1;
             $price->save();
         }
         if ($price->is_custom == '0') {
             $price->custom_price = $item->price;
             $price->save();
         }
     }
     return redirect('item')->with('message', 'Data berhasil dirubah!');
 }
示例#12
0
 /**
  * 
  * Show - Show the contents of a particular item
  * Parameter - Id # of specific item 	  
  */
 public function show($id)
 {
     $item = Item::findOrFail($id);
     return view('items.show', compact('item'));
 }
示例#13
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $data = $request->except('_token');
     $item = Item::findOrFail($id);
     $path = 'images/items/';
     $destinationPath = public_path($path);
     if ($request->hasFile('image_url')) {
         $name = $request->file('image_url')->getClientOriginalName();
         $request->file('image_url')->move($destinationPath, $name);
         $item->image_url = $path . $name;
     }
     $item->name = $data['name'];
     $item->status = (int) $data['status'];
     $item->qualtity = $data['quantity'];
     $item->save();
     return redirect()->route('admin.item.show', $item->id)->with(['message' => 'success!']);
 }
示例#14
0
 public function update($id, ItemRequest $request)
 {
     $item = Item::findOrFail($id);
     $item->update($request->all());
     return redirect('items');
 }
 public function edit(Requests\UpdateItemRequest $request)
 {
     $item = Item::findOrFail($request->item_id);
     return view('product.edititem', compact('item'));
 }
示例#16
0
 public function getGoodsDetail()
 {
     $id = $_GET['id'];
     $item = Item::findOrFail($id);
     return $item->name;
 }
示例#17
0
 public function rateItem($id, Request $req)
 {
     $item = Item::findOrFail($id);
     $item->update(['rating' => $req[0]]);
 }
示例#18
0
 /**
  * Update the specified resource in storage.
  *
  * @param  ItemRequest $request
  * @param  int $id
  * @return \Illuminate\Http\Response
  */
 public function update(ItemRequest $request, $id)
 {
     try {
         $item = Item::findOrFail($id);
         $inputs = $request->all();
         if ($request->hasFile('thumbnail')) {
             $fileName = upload($request->file('thumbnail'), 'items', $item->thumbnail);
             $inputs['thumbnail'] = $fileName;
         }
         $item->fill($inputs)->save();
         if ($request->hasFile('image')) {
             $images = $request->file('image');
             foreach ($images as $index => $image) {
                 if ($image != null) {
                     $fileName = upload($image, 'items', $item->images[$index]->image);
                     $image = new Image(['image' => $fileName]);
                     $item->images()->save($image);
                 }
             }
         }
     } catch (ModelNotFoundException $ex) {
         Flash::error('No item found' . $ex);
         return redirect()->route('store.items.index');
     }
     Flash::success('Item updated successfully');
     return redirect()->route('store.items.index');
 }
示例#19
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $item = Item::findOrFail($id);
     $item->delete();
     return redirect('inventory');
 }
示例#20
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     // 通过删除itemsite,同时删除了item
     $item = Item::findOrFail($id);
     $itemsite = $item->itemsite;
     if ($itemsite != null) {
         Itemsite::destroy($itemsite->id);
     }
     Item::destroy($id);
     return redirect('items');
 }