/** * Create a new controller instance. * * @return void */ public function index(Request $request) { $email = Option::where('key', 'contact.email')->first()->value; $phone = Option::where('key', 'contact.phone')->first()->value; $slogan = Option::where('key', 'site.slogan')->first()->value; $description = Option::where('key', 'site.description')->first()->value; $social_links = array('facebook' => Option::where('key', 'facebook.link')->first()->value, 'twitter' => Option::where('key', 'twitter.link')->first()->value, 'youtube' => Option::where('key', 'youtube.link')->first()->value, 'linkedin' => Option::where('key', 'linkedin.link')->first()->value, 'instagram' => Option::where('key', 'instagram.link')->first()->value); $data = array('photos' => Photo::orderBy('sort_order')->get(), 'employees' => Employee::orderBy('sort_order')->get(), 'email' => $email, 'phone' => $phone, 'slogan' => $slogan, 'description' => $description, 'social_links' => $social_links); return view('about', $data); }
public function index() { if (!$this->hasPermission($this->menuPermissionName)) { return view($this->viewPermissiondeniedName); } $provinces = Province::whereHas('branchs', function ($q) { $q->where('isheadquarter', true); })->orderBy('name', 'asc')->get(['id', 'name']); $provinceselectlist = array(); array_push($provinceselectlist, ':เลือกจังหวัด'); foreach ($provinces as $item) { array_push($provinceselectlist, $item->id . ':' . $item->name); } $occupations = Occupation::orderBy('name', 'asc')->get(['id', 'name']); $occupationselectlist = array(); array_push($occupationselectlist, ':เลือกอาชีพ'); foreach ($occupations as $item) { array_push($occupationselectlist, $item->id . ':' . $item->name); } $addprovinces = Province::orderBy('name', 'asc')->get(['id', 'name']); $addprovinceselectlist = array(); array_push($addprovinceselectlist, ':เลือกจังหวัด'); foreach ($addprovinces as $item) { array_push($addprovinceselectlist, $item->id . ':' . $item->name); } $amphurs = Amphur::has('customers')->orderBy('name', 'asc')->get(['id', 'name']); $amphurselectlist = array(); array_push($amphurselectlist, ':เลือกเขต/อำเภอ'); foreach ($amphurs as $item) { array_push($amphurselectlist, $item->id . ':' . $item->name); } $districts = District::has('customers')->orderBy('name', 'asc')->get(['id', 'name']); $districtselectlist = array(); array_push($districtselectlist, ':เลือกตำบล/แขวง'); foreach ($districts as $item) { array_push($districtselectlist, $item->id . ':' . $item->name); } if (Auth::user()->isadmin) { $employees = Employee::orderBy('firstname', 'asc')->orderBy('lastname', 'asc')->get(['id', 'firstname', 'lastname']); } else { $provinceid = Auth::user()->provinceid; $employees = Employee::whereHas('branch', function ($q) use($provinceid) { $q->where('provinceid', $provinceid); })->orderBy('firstname', 'asc')->orderBy('lastname', 'asc')->get(['id', 'firstname', 'lastname']); } $employeeselectlist = array(); array_push($employeeselectlist, ':เลือกพนักงาน'); foreach ($employees as $emp) { array_push($employeeselectlist, $emp->id . ':' . $emp->firstname . ' ' . $emp->lastname); } $carmodels = CarModel::whereHas("carbrand", function ($q) { $q->where('ismain', true); })->orderBy('name', 'asc')->get(['id', 'name']); $carmodelselectlist = array(); array_push($carmodelselectlist, ':เลือกแบบ'); foreach ($carmodels as $cm) { array_push($carmodelselectlist, $cm->id . ':' . $cm->name); } $colors = Color::all(['id', 'code', 'name']); $colorselectlist = array(); array_push($colorselectlist, ':เลือกสี'); foreach ($colors as $item) { array_push($colorselectlist, $item->id . ':' . $item->code . ' - ' . $item->name); } $defaultProvince = ''; if (Auth::user()->isadmin == false) { $defaultProvince = Auth::user()->provinceid; } return view($this->viewname, ['colorselectlist' => implode(";", $colorselectlist), 'provinceselectlist' => implode(";", $provinceselectlist), 'addprovinceselectlist' => implode(";", $addprovinceselectlist), 'amphurselectlist' => implode(";", $amphurselectlist), 'districtselectlist' => implode(";", $districtselectlist), 'carmodelselectlist' => implode(";", $carmodelselectlist), 'employeeselectlist' => implode(";", $employeeselectlist), 'occupationselectlist' => implode(";", $occupationselectlist), 'defaultProvince' => $defaultProvince]); }