public function show($id, Request $request) { $id = (int) my_decode($id); $data['user'] = $this->person->respondWithItem($this->person->get('person_' . $id), new UserTransformer()); //get invidvidual reports $response = $this->report->individual($id); $data['totalIReport'] = 0; $data['individual'] = []; $item = new Item(); if (!isset($response['error'])) { $data['individual'] = $this->report->respondWithCollection($response['data'], new ReportTransformer()); foreach ($data['individual'] as $i => $row) { $items = $item->getItemsByReport((int) my_decode($row['id'])); $data['individual'][$i]['items'] = $items['totalRecords']; } $data['totalIReport'] = $response['totalRecords']; } $response = $this->report->group($id); $data['totalGReport'] = 0; $data['group'] = []; if (!isset($response['error'])) { $data['group'] = $this->report->respondWithCollection($response['data'], new ReportTransformer()); foreach ($data['group'] as $i => $row) { $items = $item->getItemsByReport((int) my_decode($row['id'])); $data['group'][$i]['items'] = $items['totalRecords']; } $data['totalGReport'] = $response['totalRecords']; } return view('users_profile', $data); }
/** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function store(Request $request) { $validator = Validator::make($request->all(), ['item_name' => 'required']); if ($validator->fails()) { return redirect('dashboard')->withErrors($validator)->withInput(); } $item = $request->input('item_name'); if (!Item::where('item_name', $item)->count()) { //naya item insert hua hai $items = new Item(); $item_id = $items->insertGetId(['item_name' => $item, 'created_at' => Carbon::now()]); $data = new pivot_user_item(); $data->user_id = Auth::user()->id; $data->item_id = $item_id; $data->save(); $request->session()->flash('status', 'Item added.Add another item!'); } else { $item_id = Item::where('item_name', $item)->value('id'); if (pivot_user_item::where('item_id', $item_id)->where('user_id', Auth::user()->id)->count()) { //item agar user ka hoga to added $request->session()->flash('list', 'you have already added this item!'); } else { //item naya user add kia hai $data = new pivot_user_item(); $data->user_id = Auth::user()->id; $data->item_id = $item_id; $data->save(); $request->session()->flash('status', 'Item added.Add another item!'); } } return redirect('items'); }
public function create(Requests\ItemRequest $request) { $name = $request->name; $shortdesc = $request->shortdesc; $desc = $request->desc; $price = $request->price; $id = $request->id; $characters = 'abcdefghijklmnopqrstuvwxyz0123456789'; $string = ''; $random_string_length = 12; for ($i = 0; $i < $random_string_length; $i++) { $string .= $characters[rand(0, strlen($characters) - 1)]; } $imageName = $name . '_' . $string . '.' . $request->file($id . 'image')->getClientOriginalExtension(); $item = new Item(); $item->name = $name; $item->shortdesc = $shortdesc; $item->desc = $desc; $item->image = $imageName; $item->group_id = $id; $item->price = $price; $item->save(); $request->file($id . 'image')->move(base_path() . '/public/upload/itemimages/', $imageName); return redirect('admin/catalogue'); }
private function postAddItemStepTwo(ItemRequest $request) { //Create new item $item = new Item(); $item->name = $request->name; $item->description = $request->description; $item->price = $request->price; $item->by_mail = $request->by_mail ? 1 : 0; $item->user()->associate(Auth::user()); $item->save(); //Create new itemAttributes based on the defaultAttributes of the market foreach ($request->itemAttributes as $name => $value) { $itemAttribute = new ItemAttribute(); $itemAttribute->name = $name; $itemAttribute->value = $value; $itemAttribute->item()->associate($item); $itemAttribute->save(); } //Create new itemPhotos /*if (!empty($request->itemPhotos)) { foreach ($request->get('itemPhotos') as $itemPhoto) { var_dump($itemPhoto);exit; } }*/ }
public function index() { $person = new Person(); $report = new Report(); $item = new Item(); $role = session('user.role'); $data = ['total_users' => 0, 'total_report' => 0, 'total_item' => 0]; if ($role == 'U') { //get data on report and item only } else { if ($role == 'M') { $response = $person->getAssignedPersons(session('user.id')); if (!empty($response)) { //get total reports or their assigned users $data['total_users'] = $response['totalRecords']; foreach ($response['data'] as $row) { $reports = $report->getReportsByPerson($row['id']); if (!empty($reports['data'])) { $data['total_report'] += $reports['totalRecords']; //get item of the report foreach ($reports['data'] as $srow) { $items = $item->getItemsByReport($srow['id']); $data['total_item'] += $items['totalRecords']; } } } //get current user's report $response = $report->getReportsByPerson(session('user.id')); if (!empty($response['data'])) { $data['total_report'] += $response['totalRecords']; //get item of the report foreach ($response['data'] as $row) { $items = $item->getItemsByReport($row['id']); $data['total_item'] += $items['totalRecords']; } } } } else { //admin $response = $person->all([]); if (!empty($response)) { //get total reports or their assigned users $data['total_users'] = $response['totalRecords']; foreach ($response['data'] as $row) { $reports = $report->getReportsByPerson($row['id']); if (isset($reports['data']) && !empty($reports['data'])) { $data['total_report'] += $reports['totalRecords']; //get item of the report foreach ($reports['data'] as $srow) { $items = $item->getItemsByReport($srow['id']); $data['total_item'] += $items['totalRecords']; } } } } } } return view('dashboard', $data); }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show() { $info = new Item(); $info->setTable($this->getLoginUsername()); //$info->setTable($this->getLoginUsername()); $list = $info->all($this->getLoginUsername(), array('taskname', 'deadline', 'description', 'important')); return view('auth.profile')->with(array('username' => $this->getLoginUsername(), 'list' => $list)); }
/** * Store a newly created resource in storage. * * @param Request $request * @return Response */ public function store(Request $request) { $item = new Item(); $item->item_name = trim($request->get('item_name')); $item->item_id = (int) $request->get('item_id'); $item->save(); return redirect('/item')->withSuccess("Item {$item->item_name} was created"); }
public function getDelete(Item $task) { //echo $task; //security, make sure that the correct user deletes this task if ($task->owner_id == Auth::user()->id) { $task->delete(); } return Redirect::route('home'); }
public function store(Request $request) { $item = new Item(); $item->setSymPass($request->session()->get('sym_pass')); $item->key = $request->key; $item->val = $request->val; $item->resource_id = $request->resource_id; $item->save(); return redirect()->route('resource.show', ['id' => $request->resource_id]); }
public function save(Request $request, Response $response, array $args) { $_POST = array_filter($_POST, 'trim'); $metadata = array('id' => filter_input(INPUT_POST, 'id', FILTER_SANITIZE_NUMBER_INT), 'title' => filter_input(INPUT_POST, 'title'), 'description' => filter_input(INPUT_POST, 'description'), 'date' => filter_input(INPUT_POST, 'date'), 'date_granularity' => filter_input(INPUT_POST, 'date_granularity', FILTER_SANITIZE_NUMBER_INT), 'edit_group' => filter_input(INPUT_POST, 'edit_group', FILTER_SANITIZE_NUMBER_INT), 'read_group' => filter_input(INPUT_POST, 'read_group', FILTER_SANITIZE_NUMBER_INT)); $tags = filter_input(INPUT_POST, 'tags'); $item = new Item(null, $this->user); $item->save($metadata, $tags, $_FILES['file']['tmp_name'], filter_input(INPUT_POST, 'file_contents')); $config = new Config(); return new RedirectResponse($config->baseUrl() . '/' . $item->getId()); }
public function done(Item $item) { $login_user = Auth::user(); $child = $login_user->getChild(); $child_member_id = $child->member_id; $item_record = $item->where("member_id", "=", $child_member_id)->where('did_get', '=', NULL)->first(); $item_record->did_get = date("Y/m/d H:i:s"); $item_record->save(); return redirect()->to('/mypage/cart'); }
static function addItem($request) { $item = new Item(); $item->user_id = $request->input('user_id'); $item->name = $request->input('name'); $item->specifications = $request->input('specifications'); $item->link = $request->input('link'); $item->rank = $request->input('rank'); $item->save(); }
/** * Returns category items * * @param string $alias * @return array */ public function getCategoryItems($alias) { $categories = $this->categoryService->getCategoriesByAlias($alias); if (count($categories) === 0) { return []; } $categoryIDs = array_map(function (Category $category) { return $category->id; }, $categories); return $this->itemStorage->getCategoriesItems($categoryIDs); }
public function render(Request $request, Response $response, array $args) { $item = new Item($args['id']); $size = isset($args['size']) ? $args['size'] : 'o'; $version = isset($args['version']) ? $args['version'] : null; $cacheFile = $item->getCachePath($size, $version); $fileResponse = new BinaryFileResponse($cacheFile); $fileResponse->headers->set('Content-Type', 'image/png'); $fileResponse->setFile($cacheFile); $fileResponse->setContentDisposition(ResponseHeaderBag::DISPOSITION_INLINE, $item->getTitle() . '.png'); return $fileResponse; }
/** * Run the database seeds. * * @return void */ public function run() { $faker = Faker::create(); for ($i = 0; $i < 300; $i++) { Item::create(['name' => $faker->shuffle($faker->name()), 'description' => $faker->text(), 'icon' => $faker->imageUrl(100, 100, 'abstract')]); } }
/** * Update podcast items * * @return mixed */ public function handle() { $uniquePodcasts = DB::table('podcasts')->select('id', 'feed_url', 'machine_name')->groupBy('machine_name')->get(); foreach ($uniquePodcasts as $podcast) { $usersSubscribedToThisPodcast = DB::table('podcasts')->select('user_id', 'id as podcast_id')->where('machine_name', '=', $podcast->machine_name)->get(); $items = Feeds::make($podcast->feed_url)->get_items(); // Calculate 48 hours ago $yesterday = time() - 24 * 2 * 60 * 60; foreach ($items as $item) { $itemPubDate = $item->get_date(); if ($item->get_date('U') > $yesterday) { // new items foreach ($usersSubscribedToThisPodcast as $subscriber) { $podcastItemsCount = DB::table('items')->select('user_id', 'title', 'podcast_id')->where('title', '=', strip_tags($item->get_title()))->where('user_id', '=', $subscriber->user_id)->where('podcast_id', '=', $subscriber->podcast_id)->count(); // if this item is not already in the DB if ($podcastItemsCount == 0) { Item::create(['user_id' => $subscriber->user_id, 'title' => strip_tags($item->get_title()), 'description' => strip_tags(str_limit($item->get_description(), 100)), 'published_at' => $item->get_date('Y-m-d'), 'url' => $item->get_permalink(), 'audio_url' => $item->get_enclosure()->get_link(), 'podcast_id' => $subscriber->podcast_id]); } } } else { break; } } } }
public function getUpdate($id) { $gather = Gather::find($id); $lists = $gather->detail->lists('item_id'); $items = Item::whereNotIn('id', $lists)->get(); return view("gathers.update")->with('gather', $gather)->with('items', $items); }
public function store(Request $request) { try { $counter = $request->input('counter'); ItemOut::create($request->all()); $data = ItemOut::orderBy('created_at', 'desc')->first(); echo $counter; for ($i = 0; $i < $counter; $i++) { $qty = $request->input('qty' . strval($i)); $itemId = $request->input('item_id' . strval($i)); $isItemAvailable = Item::where('id', 'like', '%' . $itemId . '%')->first(); // Item::findOrFail($itemId); if (is_null($isItemAvailable)) { ItemOut::destroy($data->id); return redirect('itemout')->with('message', 'Data dengan kode barang: ' . $itemId . ', tidak ada'); } else { DetailItemOut::create(['qty' => $qty, 'item_id' => $itemId, 'item_out_id' => $data->id]); Item::decreaseStock($itemId, $qty); } } return redirect('itemout')->with('message', 'Data berhasil dibuat!'); } catch (\Illuminate\Database\QueryException $e) { return redirect('itemout')->with('message', 'Data dengan email tersebut sudah digunakan!'); } catch (\PDOException $e) { return redirect('itemout')->with('message', 'Data dengan email tersebut sudah digunakan!'); } }
/** * Run the database seeds. * * @return void */ public function run() { DB::table('items')->delete(); for ($i = 1; $i <= 100; $i++) { Item::create(array('title' => 'item test ' . $i)); } }
public function index(Request $request) { $request->flash(); $items = Item::search($request); // dd($request); return view('spareparts.index', compact('items')); }
public function newItem() { $type = Input::get('type'); if ($type == 1) { $ReceivingTemps = new ReceivingTemp(); $ReceivingTemps->item_id = Input::get('item_id'); $ReceivingTemps->cost_price = Input::get('cost_price'); $ReceivingTemps->total_cost = Input::get('total_cost'); $ReceivingTemps->quantity = 1; $ReceivingTemps->save(); return $ReceivingTemps; } else { $itemkits = ItemKitItem::where('item_kit_id', Input::get('item_id'))->get(); foreach ($itemkits as $value) { $item = Item::where('id', $value->item_id)->first(); $ReceivingTemps = new ReceivingTemp(); $ReceivingTemps->item_id = $value->item_id; $ReceivingTemps->cost_price = $item->cost_price; $ReceivingTemps->total_cost = $item->cost_price * $value->quantity; $ReceivingTemps->quantity = $value->quantity; $ReceivingTemps->save(); //return $ReceivingTemps; } return $ReceivingTemps; } }
public function edit($id) { $activity = Activity::find($id); $cars = Car::lists('name', 'id'); $customers = Customer::lists('name', 'id'); $locations = Location::lists('name', 'id'); $costs = null; $items = null; $ondayOtherCosts = null; if ($activity->type == "On Day") { $data = Onday::where('activity_id', '=', $id)->get()->pop(); $ondayOtherCosts = OndayOtherCost::where('onday_id', $data->id)->get(); } else { if ($activity->type == "Maintenance") { $data = Maintenance::where('activity_id', '=', $id)->get()->pop(); $costs = $activity->maintenance->items; $items = Item::lists('name', 'id')->sort(); } else { if ($activity->type == "Nil") { $data = Nil::where('activity_id', '=', $id)->get()->pop(); } } } return view('activity.edit', ['activity' => $activity, 'data' => $data, 'cars' => $cars, 'customers' => $customers, 'locations' => $locations, 'costs' => $costs, 'items' => $items, 'ondayOtherCosts' => $ondayOtherCosts]); }
public function getItemrfq(Request $request) { /* $col; if($request->s=='n'){ $col='name'; }else{ $col='item_code'; }*/ $name = $request->term; $item = Item::where('name', 'like', '%' . $name . '%')->orWhere('item_code', 'like', '%' . $name . '%')->limit(5)->get(); $result = []; foreach ($item as $itemlist) { $res = []; $res['name'] = $itemlist->name; $res['id'] = $itemlist->id; $res['item_code'] = $itemlist->item_code; $res['sell_price'] = $itemlist->price_sell; $res['description_1'] = $itemlist->description_1; $res['description_2'] = $itemlist->description_2; $res['description_3'] = $itemlist->description_3; $res['stock'] = $itemlist->stock; $res['unit'] = $itemlist->unit; $result[] = $res; } $result = array("results" => $result); return response()->json($result); }
public function run() { DB::table('items')->delete(); Item::create(['name' => 'Truc', 'description' => 'non applicable', 'price' => '99.99', 'stock' => 5, 'img_url' => '/images/filler.jpg', 'category_id' => 1]); Item::create(['name' => 'Machin', 'description' => 'non applicable', 'price' => '23.99', 'stock' => 3, 'img_url' => '/images/filler.jpg', 'category_id' => 2]); Item::create(['name' => 'Bidule', 'description' => 'non applicable', 'price' => '123.99', 'stock' => 0, 'img_url' => '/images/filler.jpg', 'category_id' => 3]); }
/** * @param $id * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector */ public function destroy($id) { $item = Item::find($id); //select the book using primary id $item->delete(); return redirect('/'); }
/** * Store a newly created resource in storage. * * @return Response */ public function store(Request $request) { $res['status'] = 400; $res['message'] = ''; $res['errors'] = []; // $input = $request->only('firstname_quote', 'lastname_quote', 'email_quote', 'phone_quote', 'date_quote', 'time_quote', 'passengers', 'pickup_addr', 'pickup_building', 'pickup_floors', 'pickup_room_no', 'pickup_elevator', 'delivery_addr', 'delivery_building', 'delivery_floors', 'delivery_room_no' , 'delivery_elevator'); $input = $request->all(); $data = $input; $rules = ['service_type' => 'required|max:150', 'name_quote' => 'required|max:150', 'email_quote' => 'required|email', 'phone_quote' => 'required', 'date_quote' => 'required|max:20', 'passengers' => 'numeric', 'pickup_addr' => 'required|max:255', 'pickup_building' => 'max:255', 'pickup_floors' => 'max:255', 'pickup_room_no' => 'max:255', 'pickup_elevator' => 'max:3', 'delivery_addr' => 'required|max:255', 'delivery_building' => 'max:255', 'delivery_floors' => 'max:255', 'delivery_room_no' => 'max:255', 'delivery_elevator' => 'max:3', 'message_quote' => 'max:1000']; $this->validate($request, $rules); $items = Item::active()->orderBy('number_in_row')->get(); foreach ($items as $item) { if (!isset($input[$item->id . '___quantity'])) { $res['message'] = 'An error occour, please refresh page and try again.'; return response()->json($res); } $data['selected_items'][$item->id]['title'] = $item->title; $data['selected_items'][$item->id]['image'] = $item->image; $data['selected_items'][$item->id]['quantity'] = (int) $input[$item->id . '___quantity']; } $res['data'] = $data; $res['status'] = 200; Mail::send('emails.quotation', $res, function ($m) use($data) { $m->to(Config::get('constants.admin')['email'], Config::get('constants.admin')['name'])->subject($data['name_quote'] . ' has filled a quotation for you.'); }); return response()->json($res); }
/** * * Store - Processes $_POSTs from the Add Item page * Parameter - CreateItemRequest */ public function store(Requests\CreateItemRequest $request) { $input = $request->all(); $input['user_id'] = Auth::id(); Item::create($input); return redirect('items'); }
public function map(){ $items = Item::all(); //$items = Item::distance(0.1,'45.05,7.6667')->get(); return view('items.map')->with(['items'=>$items]); }
/** * Display a listing of the resource. * * @return Response */ public function index() { //$items = Item::get(); //$itemkits = ItemKit::with('itemkititem')->get(); //$array = array_merge($items->toArray(), $itemkits->toArray()); //return Response::json($array); return Response::json(Item::get()); }
/** * 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')); }