Пример #1
0
 public function index()
 {
     if (!$this->hasPermission($this->menuPermissionName)) {
         return view($this->viewPermissiondeniedName);
     }
     $cartypes = CarType::orderBy('name', 'asc')->get(['id', 'name']);
     $cartypeselectlist = array();
     array_push($cartypeselectlist, ':เลือกประเภทรถ');
     foreach ($cartypes as $ct) {
         array_push($cartypeselectlist, $ct->id . ':' . $ct->name);
     }
     $carbrands = CarBrand::orderBy('name', 'asc')->get(['id', 'name']);
     $carbrandselectlist = array();
     array_push($carbrandselectlist, ':เลือกยี่ห้อรถ');
     foreach ($carbrands as $item) {
         array_push($carbrandselectlist, $item->id . ':' . $item->name);
     }
     $colors = Color::orderBy('code', 'asc')->orderBy('name', 'asc')->get(['id', 'code', 'name']);
     $colorselectlist = array();
     array_push($colorselectlist, ':เลือกสี');
     foreach ($colors as $item) {
         array_push($colorselectlist, $item->id . ':' . $item->code . ' - ' . $item->name);
     }
     $provinces = Province::orderBy('name', 'asc')->get(['id', 'name']);
     $provinceselectlist = array();
     array_push($provinceselectlist, ':เลือกจังหวัด');
     foreach ($provinces as $item) {
         array_push($provinceselectlist, $item->id . ':' . $item->name);
     }
     $defaultCarBrand = '';
     $carBrand = CarBrand::where('name', "NISSAN")->first();
     if ($carBrand != null) {
         $defaultCarBrand = $carBrand->id;
     }
     return view('settings.carmodel', ['cartypeselectlist' => implode(";", $cartypeselectlist), 'carbrandselectlist' => implode(";", $carbrandselectlist), 'colorselectlist' => implode(";", $colorselectlist), 'provinceselectlist' => implode(";", $provinceselectlist), 'defaultCarBrand' => $defaultCarBrand]);
 }
 public function getAll()
 {
     return \Response::json(array('datos' => Color::orderBy('ts_color.nombre_color')->get()));
 }