Ejemplo n.º 1
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $employee_ids = Employee::all()->lists('id')->toArray();
     $order_states = OrderState::lists('id')->toArray();
     $products = Product::all();
     $municipalities = Municipality::all();
     factory(App\Customer::class, 50)->create()->each(function ($customer) use($employee_ids, $products, $municipalities, $order_states) {
         shuffle($employee_ids);
         shuffle($order_states);
         $customer->user()->save(factory(User::class, 'customer')->create());
         $customer->city_id = $municipalities->shuffle()->first()->id;
         $customer->save();
         $customer->products()->attach($products->shuffle()->first(), ['vote' => rand(1, 5), 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
         $customer->orders()->save(factory(App\Order::class)->create(['acquired_by' => $employee_ids[0], 'state_id' => $order_states[0]]));
     });
     $user = new User();
     $user->name = 'Vid';
     $user->surname = 'Mahovic';
     $user->email = '*****@*****.**';
     $user->password = '******';
     $user->verified = true;
     $user->save();
     $customer = new Customer();
     $customer->street = 'Celovška 21';
     $customer->city_id = $municipalities->shuffle()->first()->id;
     $customer->phone = '+38640850993';
     $customer->save();
     $customer->user()->save($user);
 }
Ejemplo n.º 2
0
 public function saveCustomer(Request $request)
 {
     if ($request->customer_id != "") {
         $customer = Customer::find($request->customer_id);
         $customer->name = $request->name;
         $customer->phone = $request->phone;
         $customer->address = $request->address;
         User::where('userable_id', '=', $request->customer_id)->update(['email' => $request->email, 'banned' => $request->banned]);
         $check = $customer->save();
         if ($check) {
             return "EDIT_SUCCEED";
         } else {
             return "Có lỗi xảy ra. Vui lòng thử lại sau!";
         }
     } else {
         $customer = new Customer();
         $customer->name = $request->name;
         $customer->phone = $request->phone;
         $customer->address = $request->address;
         $check = $customer->save();
         if ($check) {
             $data = array('msg' => 'ADD_SUCCEED', 'customer_id' => $customer->id);
             return $data;
         } else {
             return "Có lỗi xảy ra. Vui lòng thử lại sau!";
         }
     }
 }
Ejemplo n.º 3
0
 /**
  * Delete a customer
  */
 public function delete(Customer $customer)
 {
     logThis('Customer Deleted: ' . $customer->name . ' was deleted.');
     $this->dispatch(new RemoveFromMonitoring($customer));
     $customer->delete();
     $this->dispatch(new RewriteDhcpConfig());
     return $customer;
 }
Ejemplo n.º 4
0
 public function saveCustomer(Request $request)
 {
     $this->validate($request, ['address' => 'required|max:200', 'number_card' => 'required|numeric|digits:16']);
     $c = new Customer();
     $c->user_id = Auth::user()->id;
     $c->address = $request->address;
     $c->number_card = $request->number_card;
     $c->number_command = 0;
     $c->save();
     return redirect('commande')->with(['message' => 'Votre inscription est complete', 'alert' => 'success']);
 }
Ejemplo n.º 5
0
 private function generateCustomerSeed($email, $password, $firstname, $surname, $dob)
 {
     $user = ['email' => $email, 'password' => bcrypt($password), 'role' => '1'];
     $user = User::create($user);
     $customer = new Customer();
     $customer->user_id = $user->id;
     $customer->firstname = $firstname;
     $customer->surname = $surname;
     $customer->dob = $dob;
     $customer->save();
 }
Ejemplo n.º 6
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $user = new User();
     $user->name = 'mugekural';
     $user->surname = str_random(10);
     $user->email = $user->name . '@gmail.com';
     $user->is_active = true;
     $user->password = bcrypt('12345');
     $user->type = 'App\\Supplier';
     $user->save();
     $supplier = new Supplier();
     $supplier->phone = '023123';
     $supplier->id = $user->id;
     $supplier->save();
     $user2 = new User();
     $user2->name = str_random(10);
     $user2->surname = str_random(10);
     $user2->email = $user2->name . '@gmail.com';
     $user2->is_active = true;
     $user2->type = 'App\\Customer';
     $user2->save();
     $customer = new Customer();
     $customer->phone = "053247557437";
     $customer->id = $user2->id;
     $customer->save();
     $instagram = new InstagramAccount();
     $instagram->instagram_id = "1231231";
     $instagram->access_token = "asdaddads";
     $instagram->username = "******";
     $instagram->full_name = "omer faruk";
     $instagram->bio = "fdsfasfdsf";
     $instagram->website = "string";
     $instagram->profile_picture = "";
     $supplier->instagramAccount()->save($instagram);
     $product = new Product();
     $product->supplier_id = $supplier->id;
     $product->id = "235";
     $product->is_active = true;
     $product->title = "kitap";
     $product->description = "martı";
     $product->price = "340";
     $product->save();
     $instagram2 = new InstagramAccount();
     $instagram2->instagram_id = "700797";
     $instagram2->access_token = "fjfjjfjfjf";
     $instagram2->username = "******";
     $instagram2->full_name = "muge kural";
     $instagram2->bio = "comp stud";
     $instagram2->website = "some string";
     $instagram2->profile_picture = "";
     $customer->instagramAccount()->save($instagram2);
 }
Ejemplo n.º 7
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $input = Request::all();
     $avto = new Avto($input);
     $repair = new Repair($input);
     $customer = new Customer($input);
     $avto->save();
     $repair->save();
     $customer->save();
     $order = new Order(['date' => $input['date'], 'd_avto' => $avto->id, 'd_r' => $repair->id, 'customer_id' => $customer->id]);
     $order->save();
     //  dd($avto);<--Для дебага
     return redirect('orders/ordersuccess');
 }
Ejemplo n.º 8
0
 /**
  * Show the form for creating a new resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function create()
 {
     $customers = Customer::all();
     //     	return view('order.create',compact('customers', $customers));
     return view('order.create', array('customers' => $customers));
     //         return view('order.create');
 }
Ejemplo n.º 9
0
 public function create()
 {
     $employees = Employee::select('id')->where('manager_id', \Auth::user()->id)->get();
     $doctors = Customer::whereIn('mr_id', $employees)->get();
     $dataView = ['doctors' => $doctors];
     return view('am.plan.create', $dataView);
 }
Ejemplo n.º 10
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $suppliers = Supplier::orderBy('name')->get();
     $employees = Employee::orderBy('firstname')->get();
     $customers = Customer::orderBy('name')->get();
     return view('inventory.home', compact(['suppliers', 'employees', 'customers']));
 }
Ejemplo n.º 11
0
 public function single($mr, $currentMonth)
 {
     $actualVisits = [];
     $MonthlyCustomerProducts = [];
     $MRLine = [];
     $doctors = Customer::where('mr_id', $mr)->get();
     foreach ($doctors as $singleDoctor) {
         $actualVisits[$singleDoctor->id] = Report::where('mr_id', $mr)->where('month', $currentMonth)->where('doctor_id', $singleDoctor->id)->count();
         $MonthlyCustomerProducts[$singleDoctor->id] = Customer::monthlyProductsBought([$singleDoctor->id])->toArray();
     }
     $products = Product::where('line_id', Employee::findOrFail($mr)->line_id)->get();
     $coverageStats = Employee::coverageStats($mr, $currentMonth);
     $allManagers = Employee::yourManagers($mr);
     $totalProducts = Employee::monthlyDirectSales($mr, $currentMonth);
     $totalSoldProductsSales = $totalProducts['totalSoldProductsSales'];
     $totalSoldProductsSalesPrice = $totalProducts['totalSoldProductsSalesPrice'];
     $currentMonth = \Carbon\Carbon::parse($currentMonth);
     $lines = MrLines::select('line_id', 'from', 'to')->where('mr_id', $mr)->get();
     foreach ($lines as $line) {
         $lineFrom = \Carbon\Carbon::parse($line->from);
         $lineTo = \Carbon\Carbon::parse($line->to);
         if (!$currentMonth->lte($lineTo) && $currentMonth->gte($lineFrom)) {
             $MRLine = MrLines::where('mr_id', $mr)->where('line_id', $line->line_id)->get();
         }
     }
     $dataView = ['doctors' => $doctors, 'MonthlyCustomerProducts' => $MonthlyCustomerProducts, 'actualVisits' => $actualVisits, 'products' => $products, 'totalVisitsCount' => $coverageStats['totalVisitsCount'], 'actualVisitsCount' => $coverageStats['actualVisitsCount'], 'totalMonthlyCoverage' => $coverageStats['totalMonthlyCoverage'], 'allManagers' => $allManagers, 'totalSoldProductsSales' => $totalSoldProductsSales, 'totalSoldProductsSalesPrice' => $totalSoldProductsSalesPrice, 'MRLines' => $MRLine];
     return view('am.line.single', $dataView);
 }
Ejemplo n.º 12
0
 public function search()
 {
     $products = Product::where('line_id', Employee::find(\Auth::user()->id)->line_id)->get();
     $doctors = Customer::where('mr_id', \Auth::user()->id)->get();
     $dataView = ['products' => $products, 'doctors' => $doctors];
     return view('mr.search.sales.search', $dataView);
 }
Ejemplo n.º 13
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($idpic)
 {
     $pic = Pic::find($idpic);
     $cust = Customer::all();
     $data = array('pic' => $pic, 'cust' => $cust);
     return View('pic.edit')->with('data', $data);
 }
Ejemplo n.º 14
0
 public function showGroup()
 {
     $customer_id = Auth::user()->customer->id;
     $group = User::with('unpaidOrders')->where('customer_id', $customer_id)->get();
     $spendings = Customer::find($customer_id)->unpaidOrders->sum('total_price');
     return view('account.group', compact('group', 'spendings'));
 }
 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'));
 }
Ejemplo n.º 16
0
 /**
  * Store the return items data 
  * 
  * @return ReturnController@index
  */
 public function store()
 {
     $input = Input::all();
     $customer = Customer::firstOrNew(['name' => $input['customer']]);
     $customer->address = $input['address'];
     $customer->save();
     $ret = new Ret();
     $ret->customer_id = $customer->id;
     $ret->date = $input['date'];
     $ret->reference_no = $input['ref_no'];
     $ret->salesman = $input['salesman'];
     $ret->area = $input['area'];
     $ret->received_by = $input['received_by'];
     $ret->checked_by = $input['checked_by'];
     $ret->save();
     foreach ($input['boxes'] as $i => $box) {
         $retItem = new ReturnItem();
         $retItem->ret_id = $ret->id;
         $retItem->box_id = $box;
         $retItem->no_of_box = $input['no_of_box'][$i];
         $retItem->no_of_packs = $input['no_of_packs'][$i];
         $retItem->amount = $input['amount'][$i];
         $retItem->product_id = Box::find($box)->product->id;
         $retItem->save();
     }
     return Redirect::action('InventoryController@index');
 }
Ejemplo n.º 17
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['subject' => 'required|max:255', 'product' => 'required', 'group' => 'required', 'severity' => 'required', 'description' => 'required']);
     $settings = Settings::where('name', 'ticket_track_id')->first();
     $track_id = $settings->str_value;
     $customer = Customer::where('id', $this->my_customer_id)->first();
     $search_strings = ['%COMPANY_NAME', '%Y', '%m', '%d'];
     $value_strings = [str_replace(' ', '_', $customer->name), date('Y', time()), date('m', time()), date('d', time())];
     $track_id = str_replace($search_strings, $value_strings, $track_id);
     $ticket = Ticket::create(['subject' => $request->subject, 'track_id' => $track_id, 'description' => $request->description, 'group_id' => $request->group, 'severity_id' => $request->severity, 'product_id' => $request->product, 'user_id' => $this->my_id, 'customer_id' => $this->my_customer_id, 'status_id' => 1]);
     if (isset($request->attachments)) {
         foreach ($request->attachments as $attachment) {
             // Check that the directory exists
             $uploadPath = storage_path() . '/attachments/' . $ticket->id;
             $fs = new Filesystem();
             if (!$fs->isDirectory($uploadPath)) {
                 // Create the directory
                 $fs->makeDirectory($uploadPath);
             }
             $attachment->move($uploadPath, $attachment->getClientOriginalName());
             $_attachment = Attachment::create(['user_id' => $this->my_id, 'name' => $attachment->getClientOriginalName(), 'ticket_id' => $ticket->id]);
         }
     }
     $this->dispatch(new EmailNewTicket($ticket));
     return redirect('/tickets');
 }
Ejemplo n.º 18
0
 /**
  * @param LoginCustomerFormRequest $request
  * @return \Illuminate\Http\RedirectResponse
  */
 public function bagStore(LoginCustomerFormRequest $request)
 {
     /////////////////////// "AUTH" CLIENT ///////////////////////
     $customer_name = Input::get('customer_name');
     $customer_email = Input::get('customer_email');
     // si username + email (provenant des inputs) match avec ceux de la bdd :
     $customer = Customer::whereRaw('username = ? and email = ?', [$customer_name, $customer_email])->first();
     if (!empty($customer)) {
         // on envois les datas en bdd :
         $order = Order::create($request->all());
         // id du client :
         $customer_id = $customer->id;
         $order->customer_id = $customer_id;
         $order->save();
         // On va associer LA commande aux produits en bdd :
         $paniers = Session::get("panier");
         $newItems = [];
         foreach ($paniers as $panier) {
             $newItems[] = ['order_id' => $order->id, 'product_id' => $panier["product_id"], 'quantity' => $panier["quantity"]];
         }
         DB::table('order_product')->insert($newItems);
         // on vide le panier :
         Session::forget('panier');
         return redirect(url('/'))->with('message', 'Votre commande à bien été pris en compte !');
     } else {
         return redirect()->back()->with('error', 'Erreur, nom d\'utilisateur ou mot de passe incorrect !');
     }
 }
Ejemplo n.º 19
0
 public function store()
 {
     $input = Input::all();
     $salesman = isset($input['salesman']) ? $input['salesman'] : null;
     $customer = Customer::firstOrNew(['name' => $input['name'], 'address' => $input['address']]);
     $customer->save();
     $order = new Order();
     $order->customer_id = $customer->id;
     $order->salesman_id = $salesman;
     $order->date = $input['date'];
     $order->type = $input['type'];
     $order->save();
     foreach ($input['box_id'] as $i => $box_id) {
         $orderItem = new OrderItem();
         $orderItem->order_id = $order->id;
         $orderItem->product_id = Box::find($box_id)->product->id;
         $orderItem->box_id = $box_id;
         $orderItem->no_of_box = $input['no_of_box'][$i];
         $orderItem->no_of_packs = $input['no_of_packs'][$i];
         $orderItem->amount = $input['amount'][$i];
         $orderItem->selling_price = $input['selling_price'][$i];
         $orderItem->save();
     }
     return view('order.addmore');
 }
Ejemplo n.º 20
0
 public function storeCustomer(Request $request)
 {
     $this->validate($request, ['address' => 'required|max:200', 'number_card' => 'required|numeric|digits:16']);
     $customer = ['user_id' => Auth::user()->id, 'address' => $request->input('address'), 'number_card' => $request->input('number_card'), 'number_command' => 0];
     Customer::create($customer);
     return redirect('validateCart')->with(['message' => trans('app.customerSuccess'), 'alert' => 'success']);
 }
Ejemplo n.º 21
0
 public function stores()
 {
     $accounts = Account::all();
     $data = array();
     foreach ($accounts as $account) {
         $customers = Customer::where('account_id', $account->id)->get();
         $account_children = array();
         foreach ($customers as $customer) {
             $areas = Area::where('customer_id', $customer->id)->get();
             $customer_children = array();
             foreach ($areas as $area) {
                 $regions = Region::where('area_id', $area->id)->get();
                 $area_children = array();
                 foreach ($regions as $region) {
                     $distributors = Distributor::where('region_id', $region->id)->get();
                     $region_children = array();
                     foreach ($distributors as $distributor) {
                         $stores = Store::where('distributor_id', $distributor->id)->get();
                         $distributor_children = array();
                         foreach ($stores as $store) {
                             $distributor_children[] = array('title' => $store->store, 'key' => $account->id . "." . $customer->id . "." . $area->id . "." . $region->id . "." . $distributor->id . "." . $store->id);
                         }
                         $region_children[] = array('select' => true, 'title' => $distributor->distributor, 'isFolder' => true, 'key' => $account->id . "." . $customer->id . "." . $area->id . "." . $region->id . "." . $distributor->id, 'children' => $distributor_children);
                     }
                     $area_children[] = array('select' => true, 'title' => $region->region, 'isFolder' => true, 'key' => $account->id . "." . $customer->id . "." . $area->id . "." . $region->id, 'children' => $region_children);
                 }
                 $customer_children[] = array('select' => true, 'title' => $area->area, 'isFolder' => true, 'key' => $account->id . "." . $customer->id . "." . $area->id, 'children' => $area_children);
             }
             $account_children[] = array('select' => true, 'title' => $customer->customer, 'isFolder' => true, 'key' => $account->id . "." . $customer->id, 'children' => $customer_children);
         }
         $data[] = array('title' => $account->account, 'isFolder' => true, 'key' => $account->id, 'children' => $account_children);
     }
     return response()->json($data);
 }
Ejemplo n.º 22
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($idkas)
 {
     $kas = Kas::find($idkas);
     $cust = Customer::all();
     $data = array('kas' => $kas, 'cust' => $cust);
     return View('kas.edit')->with('data', $data);
 }
Ejemplo n.º 23
0
 public function redeemCoupon(request $request)
 {
     $rules = array('client_id' => 'required', 'client_secret' => 'required', 'code' => 'required', 'mobile' => 'required|size:10', 'email' => 'required|email|max:255');
     $validator = $this->customValidator($request->all(), $rules, array());
     if ($validator->fails()) {
         return response()->json(['response_code' => 'ERR_RULES', 'message' => $validator->errors()->all()], 400);
     }
     $auth = $request->only('client_id', 'client_secret');
     $server = ['client_id' => Config::get('custom.client_id'), 'client_secret' => Config::get('custom.client_secret')];
     if ($server['client_id'] != $auth['client_id'] || $server['client_secret'] != $auth['client_secret']) {
         return response()->json(['response_code' => 'ERR_IAC', 'messages' => 'Invalid Api credentials'], 403);
     }
     $code = $request->only('code');
     $matchThese = ['code' => $code['code'], 'is_active' => true];
     $store = Store::where($matchThese)->first();
     if ($store == '' || empty($store)) {
         return response()->json(['response_code' => 'ERR_CCNV', 'message' => 'Coupon Code Not valid'], 409);
     }
     if ($this->userExists($request->only('email'))) {
         return response()->json(['response_code' => 'ERR_UAUC', 'message' => 'User Already Used Coupon'], 409);
     }
     $input = $request->only('name', 'email', 'mobile');
     $input['store_id'] = $store->id;
     $customer = Customer::create($input);
     $data['timer'] = $store->timer;
     $data['offer_image'] = URL::to('/assets/img/stores/') . $store->offer_image;
     return response()->json(['response_code' => 'RES_CRS', 'message' => 'Coupon Redeemed successfully', 'data' => $data]);
 }
 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     //
     parent::boot($router);
     /*Route::model*/
     /**
      * Route model binding altering default logic
      * $router->bind('articles',function($id){
      *     return \App\Article::published()->findOrFail($id);
      * });
      */
     /*Using wildcard*/
     /*$router->model('articles','App\Article');*/
     $router->bind('articles', function ($id) {
         return \App\Article::published()->findOrFail($id);
     });
     $router->bind('rates', function ($id) {
         return \App\Rate::where('id', $id)->firstOrFail();
     });
     $router->bind('customers', function ($id) {
         return \App\Customer::where('id', $id)->firstOrFail();
     });
     $router->bind('tags', function ($name) {
         return \App\Tag::where('name', $name)->firstOrFail();
     });
     $router->bind('motherboards', function ($name) {
         return \App\Motherboard::where('name', $name)->firstOrFail();
     });
 }
Ejemplo n.º 25
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $person = Person::findOrFail($id);
     $customer = Customer::findOrFail($person->customer_id);
     $person->delete();
     return Redirect::action('CustomersController@show', [$customer->slug]);
 }
Ejemplo n.º 26
0
 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 createReservation(Request $request)
 {
     $room_info = $request['room_info'];
     $start_dt = Carbon::createFromFormat('d-m-Y', $request['start_dt'])->toDateString();
     $end_dt = Carbon::createFromFormat('d-m-Y', $request['end_dt'])->toDateString();
     $customer = Customer::firstOrCreate($request['customer']);
     $reservation = Reservation::create();
     $reservation->total_price = $room_info['total_price'];
     $reservation->occupancy = $request['occupancy'];
     $reservation->customer_id = $customer->id;
     $reservation->checkin = $start_dt;
     $reservation->checkout = $end_dt;
     $reservation->save();
     $date = $start_dt;
     while (strtotime($date) < strtotime($end_dt)) {
         $room_calendar = RoomCalendar::where('day', '=', $date)->where('room_type_id', '=', $room_info['id'])->first();
         $night = ReservationNight::create();
         $night->day = $date;
         $night->rate = $room_calendar->rate;
         $night->room_type_id = $room_info['id'];
         $night->reservation_id = $reservation->id;
         $room_calendar->availability--;
         $room_calendar->reservations++;
         $room_calendar->save();
         $night->save();
         $date = date("Y-m-d", strtotime("+1 day", strtotime($date)));
     }
     $nights = $reservation->nights;
     $customer = $reservation->customer;
     return $reservation;
 }
Ejemplo n.º 28
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     //Truncate
     DB::statement('SET FOREIGN_KEY_CHECKS=0;');
     User::truncate();
     Admin::truncate();
     Customer::truncate();
     Address::truncate();
     Category::truncate();
     Product::truncate();
     Brand::truncate();
     Type::truncate();
     Image::truncate();
     DB::statement('TRUNCATE category_product;');
     Product::clearIndices();
     Product::reindex();
     //Unguard
     Model::unguard();
     //Call
     $this->call(UsersTableSeeder::class);
     $this->call(ProductsTableSeeder::class);
     //Reguard
     Model::reguard();
     DB::statement('SET FOREIGN_KEY_CHECKS=1;');
 }
Ejemplo n.º 29
0
 public function run()
 {
     Illuminate\Support\Facades\DB::table('customers')->delete();
     for ($i = 0; $i < 50; $i++) {
         Customer::create(['name' => '测试客户' . ($i + 1), 'phoneNum' => (string) (15253212675.0 + $i), 'wx' => 'jm_god_father_' . $i, 'address' => '青岛市香港中路132号3号楼1505', 'customer_category_id' => $i % 2 == 0 ? 1 : 2]);
     }
 }
 /**
  * Get request from profile form and update the fields of the Customer instance.
  * Then redirect to their intended location or '/'
  *
  * @param Request $request
  * @return \Illuminate\Http\RedirectResponse
  */
 public function profileUpdate(UpdateProfileRequest $request)
 {
     // Retrieve all data in $request to an array
     $data = $request->all();
     // Find and retrieve the appropriate Customer instance
     $customer = Customer::where('email', Auth::user()->email)->first();
     // Update the details
     $customer->name = $data['name'];
     $customer->NIC_passport_num = $data['ID'];
     $customer->telephone_num = $data['telephone'];
     $customer->address_line_1 = $data['address_line1'];
     $customer->address_line_2 = $data['address_line2'];
     $customer->city = $data['city'];
     $customer->province_state = $data['province'];
     $customer->zip_code = $data['zipCode'];
     $customer->country = $data['country'];
     // Save the updated Customer instance
     $customer->save();
     //this lines are added, if the user is facebook logged in user he needs to fill his other details and he should be
     //redirected to payment page, since return redirect()->intended() is not working for this purpose
     if (Session::has('fblogin_payment')) {
         return redirect('payment');
     }
     return redirect()->intended('/')->with('success', 'Your details have been updated successfully.');
 }