public function start() { $session = Session::get('start_session'); if ($session) { $data['title'] = "Welcome"; $user = User::find($session['user_id']); $profile = new \stdClass(); $profile->id = $user->id; $profile->profile_picture = $user->owner->profile_picture()->path(); $profile->first_name = $user->owner->first_name; $profile->last_name = $user->owner->last_name; $profile->username = $user->username; $profile->contacts = new \stdClass(); $profile->contact = $user->active_contact; foreach ($user->owner->company_person as $contact) { $profile->contacts->{$contact->id} = $contact; if (!isset($profile->first_contact)) { $profile->first_contact = $contact->id; } } $data['profile'] = $profile; $data['departments'] = Department::orderBy("name")->get(); $data['titles'] = Title::orderBy("name")->get(); return view('login.start', $data); } else { return redirect()->intended(); } }
public function edit($id) { $company_person = CompanyPerson::find($id); if (Auth::user()->can('update-contact') || Auth::user()->active_contact->id == $id && Auth::user()->can('update-own-contact') || !$company_person->isE80() && Auth::user()->can('update-customer-contact')) { $data['title'] = "Edit Contact"; $data['titles'] = Title::orderBy("name")->get(); $data['departments'] = Department::orderBy("name")->get(); $data['companies'] = Company::orderBy("name")->get(); $data['contact'] = CompanyPerson::find($id); $data['divisions'] = Division::orderBy("name")->get(); $data['groups'] = Group::where("group_type_id", "=", $company_person->group_type_id)->orderBy("name")->get(); return view('company_person/edit', $data); } else { return redirect()->back()->withErrors(['Access denied to contacts edit page']); } }
public function getEdit($id) { $user = User::find($id); $departments = Department::orderBy('dw', 'asc')->get(); $majors = Major::orderBy('zy', 'asc')->get(); $groups = Group::orderBy('id', 'asc')->get(); return view('user.edit', ['title' => '编辑用户', 'user' => $user, 'departments' => $departments, 'majors' => $majors, 'groups' => $groups]); }
public function create() { if (Auth::user()->can('create-company')) { $data['titles'] = Title::orderBy("name")->get(); $data['departments'] = Department::orderBy("name")->get(); $data['support_types'] = SupportType::orderBy("name")->get(); $data['connection_types'] = ConnectionType::orderBy("name")->get(); $data['group_types'] = GroupType::orderBy("name")->get(); $data['escalation_profiles'] = EscalationProfile::orderBy("name")->get(); $data['account_managers'] = CompanyPersonController::API()->all(["where" => ["company_person.company_id|=|" . ELETTRIC80_COMPANY_ID, "company_person.title_id|=|" . ACCOUNT_MANAGER_TITLE_ID], "order" => ["people.last_name|ASC", "people.first_name|ASC"], "paginate" => "false"]); $data['title'] = "Create Company"; return view('companies/create', $data); } else { return redirect()->back()->withErrors(['Access denied to companies create page']); } }