public function detail(Request $request) { $slug = $request->route('slug'); $array_slug = explode('-', $slug); $count_array = count($array_slug); $service_id = $array_slug[$count_array - 1]; // Get info service $info_service = Service::with(['serviceDetails' => function ($query) { $query->where('language_code', '=', App::getLocale()); }])->find($service_id); $service = new Service(); return view('service_subpage', compact('info_service', 'service')); }
public function index(Router $router) { // $routeCollection = $router->getRoutes(); // foreach ($routeCollection as $value) { // echo $value->getPath().'<br>'; // } // dd(); dd(Module::select(['name', 'route_key'])->get()->toArray()); $title = 'Dashboard'; $users = User::count(); $static_page = StaticPage::count(); $services = Service::count(); $members = Member::count(); $contacts = Contact::count(); return view('admin.dashboard.index', compact('title', 'users', 'static_page', 'services', 'members', 'contacts')); }
/** * Get the option select service. * * @return String option format for select box */ public function selectBoxService($select_id = '') { $str_return = ''; $list_services = Service::with(['serviceDetails' => function ($query) { $query->where('language_code', '=', AppLanguage::getDefaultLanguage()); }])->where('is_active', '=', '1')->get(); if ($list_services) { foreach ($list_services as $service) { foreach ($service->serviceDetails as $info_service) { $service_id = $service->id; if ($service_id == $select_id) { $attribute_option = 'selected'; } else { $attribute_option = ''; } $str_return .= "<option value='" . $service_id . "' " . $attribute_option . '>' . $info_service->service_name . '</option>'; } } } return $str_return; }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * * @return \Illuminate\Http\Response */ public function saveUpdate(Request $request) { $service_id = $request->input('service_id'); if ($service_id) { $services = new Service(); $affected_row = $services->saveData($request, $service_id); if ($affected_row) { $service_details = new ServiceDetail(); $affected_row = $service_details->saveDetails($service_id, $request); if (!$affected_row) { return redirect()->route('cpanel.service.index')->with('status', 'fail')->with('msg', 'Can not save data.'); } else { return redirect()->route('cpanel.service.index')->with('status', 'success')->with('msg', 'Successfully !'); } } else { return redirect()->route('cpanel.service.index')->with('status', 'fail')->with('msg', 'Can not save data.'); } } else { return redirect()->route('cpanel.service.index')->with('status', 'fail')->with('msg', 'Service is not avalable.'); } }