public function getDeleteDriver($id) { $order = $this->API->call(API::dispatcher_drivers . "/{$id}", 'DELETE'); if ($order->status_code != 200) { return redirect()->back()->withErrors($order->error); } return redirect()->action('Front\\Dispatcher\\DriverController@getDrivers')->withSuccess('Driver deleted successfully'); }
public function postEditOrder(Request $request, $id) { $order = $this->API->call(API::driver_orders . "/{$id}", 'PUT', $request->all()); if ($order->status_code != 200) { return redirect()->back()->withErrors($order->error); } return redirect()->action('Front\\Driver\\OrderController@getOrders')->withSuccess('Order updated successfully'); }
public function getShowOrder($order_id) { $order = $this->API->call(API::admin_orders . "/{$order_id}"); if ($order->status_code != 200) { return redirect()->back()->withErrors($order->error); } $order = $order->data; return view('admin.orders.show', compact('order')); }
public function postLogin(LoginRequest $loginRequest) { $response = $this->API->call(API::login_url, 'post', ['email' => $loginRequest->get('email'), 'password' => $loginRequest->get('password')]); if ($response->status_code == '200') { session(['email' => $loginRequest->get('email'), 'password' => $loginRequest->get('password'), 'user' => $response->data]); return redirect()->to('/frontend/home/home')->withSuccess('Logged in successfully'); } return redirect()->back()->withErrors([$response->error->message]); }
public function getLocations() { $locations = $this->API->call(API::driver_locations); if ($locations->status_code != 200) { return redirect()->back()->withErrors($locations->error); } $locations = $locations->data; return view('driver.locations.index', compact('locations')); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if (!$request->session()->has('email') || !$request->session()->has('password')) { $request->session()->forget('user'); return redirect()->action('Front\\LoginController@getLogin')->withErrors(['You are not authenticated!']); } $response = $this->API->checkCrediantials(); if ($response->status_code != '200') { $request->session()->forget('user'); $request->session()->forget('email'); $request->session()->forget('password'); return redirect()->action('Front\\LoginController@getLogin')->withErrors([$response->error->message]); } session(['user' => $response->data]); return $next($request); }
public function postCreateDriver(Request $request) { $admin = $this->API->call(API::admin_dispatchers_drivers . '/' . $request->get('dispatcher_id') . '/drivers', 'POST', $request->all()); if ($admin->status_code != 201) { return redirect()->back()->withErrors($admin->error); } return redirect()->action('Front\\Admin\\UserController@getDrivers')->withSuccess('Driver created successfully'); }