public function show(Client $client) { //get all projects for this client $projects = $client->projects()->get(); // $projects = $client->projects()->where()->get(); return view('clients.show', compact('client', 'projects')); }
/** * Remove the specified resource from storage. * DELETE /users/{id} * * @param int $id * @return Response */ public function destroy($id) { // Delete everything related to the user Task::where('user_id', Auth::id())->delete(); Credential::where('user_id', Auth::id())->delete(); Project::where('user_id', Auth::id())->delete(); Client::where('user_id', Auth::id())->delete(); User::where('id', Auth::id())->delete(); // Logout and redirect back to home page Auth::logout(); return Redirect::to('/'); }
public function update(Request $request, $id) { $client = Client::where('id', $id)->first(); $client->surname = $request->input('surname'); $client->name = $request->input('name'); $client->age = $request->input('age'); $client->room_id = $request->input('room_id'); $client->save(); $room = $request->input('room_id'); $false = Room::where('id', $room)->first(); $false->free = 0; $false->save(); return $client; }
private function _get_user_client() { return Client::where('user_id', '=', Auth::user()->id)->first()->id; }
private function clientInfo() { $client = Client::get_instance(); $forvard = getenv('HTTP_X_FORWARDED_FOR'); $client->ip = !empty($forvard) ? $forvard : isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : null; }
/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function storeClient() { $data = Input::all(); $validateClient = Validator::make($data, Client::$rules); $validateUser = Validator::make($data, User::$rules); $validatePet = Validator::make($data, Pet::$rules); if ($validateClient->fails() or $validateUser->fails() or $validatePet->fails()) { $validationMessages = array_merge_recursive($validateClient->messages()->toArray(), $validateUser->messages()->toArray(), $validatePet->messages()->toArray()); return Redirect::back()->withErrors($validationMessages)->withInput(); } $data['client_id'] = DB::table('users')->insertGetId(['email' => $data['email'], 'password' => Hash::make(Input::get('password')), 'roll' => 'client']); Client::create($data); $data['image'] = $_FILES['file']['name']; Pet::create($data); //PLACE IMAGE INTO THIS DESTINATION PATH// $destinationPath = 'images/clients'; $fileName = $data['image']; Request::file('file')->move($destinationPath, $fileName); Mail::send('emails.client_registration', ['data' => $data], function ($message) use($data) { $message->to($data['email'])->subject('Thanks for signing up!'); }); return Redirect::to('landing'); }