function getParentPerson($parent_id) { if ($parent_id > 0) { $person = Person::find($parent_id); if (count($person) > 0) { return $person->lastname . " " . $person->surname; } else { return ""; } } else { return ""; } }
public function addTeam($id) { $person = Person::find($id); if ($person === null) { return $this->personNotExistsRedirect($id); } $team_id = (int) Input::get('team'); if (!$person->teams()->where('team_id', $team_id)->exists()) { $person->teams()->attach($team_id); } return redirect()->route('person.edit', $person->id); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { if (Gate::denies('destroy', Person::class)) { abort(403); } $record = Person::find($id); Person::destroy($id); return redirect('/person')->with('alert-info', 'The record has been deleted!'); }
public function getStats($season) { $pairs = $this->pairs()->where('season_id', '=', $season->id)->get(); foreach ($pairs as $pair) { $matches = array(); $firstMatches = $pair->firstMatches()->get(); foreach ($firstMatches as $match) { $dataMatch = ['id' => $match->id, 'home' => Club::find($match->home_id)->name, 'away' => Club::find($match->away_id)->name, 'round_id' => $match->round_id, 'type' => 0]; array_push($matches, $dataMatch); } $secondMatches = $pair->secondMatches()->get(); foreach ($secondMatches as $match) { $dataMatch = ['id' => $match->id, 'home' => Club::find($match->home_id)->name, 'away' => Club::find($match->away_id)->name, 'round_id' => $match->round_id, 'type' => 1]; array_push($matches, $dataMatch); } $pair['ref1'] = Person::find($pair->ref1_id); $pair['ref2'] = Person::find($pair->ref2_id); $pair['countFall'] = count($firstMatches); $pair['countSpring'] = count($secondMatches); $pair['matches'] = $matches; } $courts = $this->referees()->wherePivot('type', '=', 1)->wherePivot('season_id', '=', $season->id)->get(); foreach ($courts as $court) { $matches = array(); $firstMatches = $court->firstMatchesAsCourt()->get(); foreach ($firstMatches as $match) { $dataMatch = ['id' => $match->id, 'home' => Club::find($match->home_id)->name, 'away' => Club::find($match->away_id)->name, 'round_id' => $match->round_id, 'type' => 0]; array_push($matches, $dataMatch); } $secondMatches = $court->secondMatchesAsCourt()->get(); foreach ($secondMatches as $match) { $dataMatch = ['id' => $match->id, 'home' => Club::find($match->home_id)->name, 'away' => Club::find($match->away_id)->name, 'round_id' => $match->round_id, 'type' => 1]; array_push($matches, $dataMatch); } $court['countFall'] = count($firstMatches); $court['countSpring'] = count($secondMatches); $court['matches'] = $matches; } $response = array('pairs' => $pairs, 'courts' => $courts); return $response; }
/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function edit(Request $request, $id) { $item = Person::find($id); if ($request->ajax()) { $list = Input::get('id'); return $this->edit_ajax($list, $item); } if ($item == null) { return Redirect::to(URL::to('datatables', ['profesores', 'see']))->with('error', 'id-nn'); } return view('person.createdit', compact('item')); }
public function person($id) { if (isset($id)) { return Person::find($id); } }
/** * Sort the specified resource from storage. * */ public function sort() { foreach (\Input::get('people') as $key => $id) { Person::find($id)->update(['line' => $key]); } \Activity::log('Kişilerin Sıralaması Değiştirildi'); }
/** * Guarda los cambio del usuario. * * @param Request $request peticion * * @return Laravel Redirect */ public function saveProfile(Request $request) { $user = \Auth::user(); $v = \Validator::make($request->all(), $this->form_rules); if ($v->fails()) { return redirect()->back()->withErrors($v->errors())->withInput(); } //user update \Session::flash('message', trans('user.saved')); $user->fill($request->all()); $user->pic_url = $request->get('pic_url'); $user->password = bcrypt($request->get('password')); $user->save(); //bussiness update if ($request->get('business_name') !== null && trim($request->get('business_name')) != '') { $business = Business::find($user->id); $business->business_name = $request->get('business_name'); $business->save(); } //person update if ($request->get('first_name') !== null && trim($request->get('first_name')) != '') { $person = Person::find($user->id); $person->first_name = $request->get('first_name'); $person->last_name = $request->get('last_name'); $person->birthday = $request->get('birthday'); $person->sex = $request->get('sex'); $person->save(); } return redirect()->back(); }
/** * Get all of the persons by ID. * * @param Person $person * * @return Collection */ public function byId($personId) { return Person::find($personId); }
/** * Validate AND Save/Crate a new task. * * @param Request $request * @return Response */ public function store(Request $request) { //check if tags belong all to the category_id foreach (explode(",", $request->tags) as $temp) { $t = Tag::find($temp); if ($t) { if ($t->category_id != $request->category) { return Redirect::back()->withErrors('Tag ' . $t->name . ' is from the wrong category!')->withInput(); } } } $date = False; $birthday = False; if ($request->birthdate) { $date = DateTime::createFromFormat('d.m.Y', $request->birthdate); $birthday = $date->format('m-d'); $date = $date->format('Y-m-d'); } $gender = ''; if ($request->gender) { $gender = $request->gender; } $input = array('lastname' => $request->lastname, 'surname' => $request->surname, 'searchname' => $request->lastname . ' ' . $request->surname, 'gender' => $gender, 'phone' => $request->phone, 'mobile' => $request->mobile, 'mail' => $request->mail, 'birthdate' => $date, 'birthday' => $birthday, 'category_id' => $request->category, 'tag_ids' => $request->tags, 'parent_id' => $request->parent_id, 'salutation' => $request->salutation, 'street' => $request->street, 'plz' => $request->plz, 'city' => $request->city, 'country' => $request->country); if ($request->person_id) { $person = Person::find($request->person_id); $person->fill($input)->save(); $request->session()->flash('alert-success', 'Person was successful updated!'); } else { $person = new Person(); $person = $person->create($input); $request->session()->flash('alert-success', 'Person was successful added!'); } $page = $request->session()->get('person_page'); if ($request->save_edit or $request->save_edit_hidden) { return redirect('/person/' . $person->id . '/update?page=' . $page); } else { return redirect('/persons?page=' . $page); } }
public static function getUsersChurch() { return \App\Person::find(\Session::get('user')->person_id)->church; }
public function myAccount() { $user = Auth::user(); $person = Person::find($user->person_id); return View('home/account', ['name' => $person->first_name]); }