public function userHistoric()
 {
     $user_id = Auth::user()->id;
     $customer_id = Customer::where('user_id', '=', $user_id)->value('id');
     $histories = History::where('customer_id', '=', $customer_id)->get();
     return view('front.user_historic', compact('histories'));
 }
 public function detailOrder($id)
 {
     $lignesCommande = History::where('order_number', '=', $id)->get();
     return view('front.detailorder', compact('lignesCommande', 'id'));
 }
 public function showCurrentBasket()
 {
     $basket = History::where('id', 1)->with('user', 'historyproducts', 'products')->First();
     return view('basket', compact('basket', 'products'));
 }
Example #4
0
 public function getLastDisposition()
 {
     return History::where('record_id', $this->id)->orderBy('created_at', 'DESC')->first();
 }
Example #5
0
 public function getMonthCount($month)
 {
     return count(History::where('action', 'sms.send')->where('user_id', $this->id)->whereMonth('created_at', '=', $month)->get());
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $deletehistory = Input::get('list');
     if ($deletehistory) {
         foreach ($deletehistory as $delete) {
             $historydel = History::where('id', $delete)->delete();
         }
         Session::flash('message', 'Successfully deleted');
     } else {
     }
     return Redirect::to('history');
 }
 /**
  * Remove the beer from a user's cellar
  *
  * @param Request $request
  * @return \Illuminate\Contracts\Routing\ResponseFactory|\Symfony\Component\HttpFoundation\Response
  */
 public function destroyBeer(Request $request)
 {
     $validator = Validator::make($request->all(), ['beer' => 'required|integer|exists:beers,id']);
     if ($validator->fails()) {
         return response(['status' => 'failed', 'message' => 'Invalid data.', 'errors' => $validator->errors()->all()], 400);
     }
     // make sure the user actually has the beer in their cellar before removing it
     $beer = History::where('user_id', '=', $this->user->id)->where('beer_id', '=', $request->get('beer'))->first();
     if (count($beer) == 0) {
         return response(['status' => 'failed', 'message' => 'Beer does not exist in cellar'], 400);
     }
     $beer->delete();
     return response(['status' => 'ok', 'message' => 'The beer has been removed from the cellar']);
 }
Example #8
0
 public function indexHistory()
 {
     $sent = History::where('action', 'sms.send')->where('user_id', \Auth::user()->id)->orderBy('created_at', 'desc')->get();
     return view('sms.history')->withSent($sent);
 }
Example #9
0
 /**
  * Display the customer details and his order histories
  */
 public function account()
 {
     $user_id = Auth::user()->id;
     $user = User::find($user_id);
     $customer = $user->customer;
     if ($customer == null) {
         $title = "My account";
         return view('front.account', compact('user', 'title'));
     } else {
         $histories = History::where('customer_id', $customer->id)->orderBy('command_id', 'desc')->paginate(10);
         $title = "My account";
         return view('front.account', compact('user', 'customer', 'histories', 'title'));
     }
 }
 private function saveHistory($id, $weight)
 {
     $history = App\History::where('user_id', '=', $id)->where('day', '=', date('Y-m-d'))->get();
     if (!count($history)) {
         $history = new History();
         $history->user_id = $id;
         $history->weight = $weight;
         $history->day = date('Y-m-d');
         $history->save();
     }
 }
Example #11
0
 public function addHistory(Request $request, Skill $skill)
 {
     $user = Auth::user();
     $input = $request->all();
     $validator = Validator::make($request->all(), ['title' => 'required', 'start_year' => 'required | integer', 'end_year' => 'required | integer | min:' . $request->input('start_year'), 'penetration' => 'required | in:1,2,3,4']);
     if ($validator->fails()) {
         return ['hasCallback' => 0, 'callback' => '', 'hasMsg' => 1, 'msg' => trans('profile.invalidHistory'), 'msgType' => 'danger', 'returns' => $validator->errors()->all()];
     }
     if ($request->hasFile('sample_file')) {
         $file = $request->file('sample_file');
         $imageName = $user->id . str_random(20) . '.' . $file->getClientOriginalExtension();
         $file->move(public_path() . '/img/files/' . $user->id . '/', $imageName);
         $user->usage->add(filesize(public_path() . '/img/files/' . $user->id . '/' . $imageName) / (1024 * 1024));
         // storage add
         $real_name = $file->getClientOriginalName();
         $size = $file->getClientSize() / (1024 * 1024);
         //calculate the file size in MB
         $input['file'] = $imageName;
     }
     $history = $skill->histories()->create($input);
     if ($request->hasFile('sample_file')) {
         History::where('id', $history->id)->first()->files()->create(['user_id' => $user->id, 'real_name' => $real_name, 'name' => $user->id . '/' . $imageName, 'size' => $size]);
     }
     return ['hasCallback' => '1', 'callback' => 'skill_histories', 'hasMsg' => 0, 'msg' => '', 'returns' => $skill->histories()->with('files')->get()];
 }