public function getImage(Request $request, $imageable_id, $imageable_type)
 {
     //\DB::enableQueryLog();
     $ModelVehicle = new Vehicle();
     $Vehicle = $ModelVehicle->find($imageable_id);
     $photos = $Vehicle->photos;
     //print_r(\DB::getQueryLog());exit;
     $result = array();
     //$files = scandir($storeFolder);                 //1
     foreach ($photos as $file) {
         $obj['id'] = $file->id;
         $obj['name'] = $file->name;
         $obj['size'] = filesize(config('assets.images.paths.original') . $file->name);
         $result[] = $obj;
     }
     return response()->json($result);
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(EditVehicleRequest $request, $vehicle_id)
 {
     //echo '<pre>'; print_r($request->all());exit;
     $input = $request->only(['name', 'category_id', 'price', 'description', 'model_id', 'is_active', 'meta_title', 'meta_keywords', 'meta_description']);
     $checkbox_name_ids = $request->get('check_validate');
     $radio_name_ids = $request->get('radio_validate');
     //$temp = array_merge($checkbox_name_ids,$radio_name_ids);
     $features = null;
     if (0 < count($checkbox_name_ids)) {
         foreach ($checkbox_name_ids as $id) {
             if ($features != '') {
                 $features .= ',' . implode(',', $request->get('features_checkbox_' . $id));
             } else {
                 $features .= implode(',', $request->get('features_checkbox_' . $id));
             }
         }
     }
     //echo $features.'<br>';exit;
     if (0 < count($radio_name_ids)) {
         $temp = [];
         foreach ($radio_name_ids as $id) {
             $temp[] = $request->get('features_radio_' . $id);
         }
         $features .= ',' . implode(',', $temp);
     }
     $input['features'] = $features;
     //echo '<pre>'; print_r($input);exit;
     $ModelVehicle = new Vehicle();
     $result = $ModelVehicle->edit($vehicle_id, $input);
     if ($result['status'] && !isset($result['tab'])) {
         return redirect(admin_route('vehicle.show', $vehicle_id))->with(array('success' => Lang::get('messages.crud.success', array('action' => 'updated'))));
     } elseif (!$result['status'] && isset($result['tab'])) {
         return redirect(admin_route('vehicle.edit', ['id' => $result['id'], 'tab' => $result['tab']]))->withErrors(['error' => $result['error']]);
     } else {
         return back()->withErrors(['error' => $result['msg']]);
     }
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id, Request $request)
 {
     $tab = $request->get('tab', null);
     $ModelVehicle = new \SmartCarBazar\Models\Vehicle();
     $Brands = new \SmartCarBazar\Models\Brand\Model();
     $Category = new \SmartCarBazar\Models\Category();
     $ModelFeatureCategory = new \SmartCarBazar\Models\FeatureCategory();
     $FeatureCategory = $ModelFeatureCategory->getAll();
     //\DB::enableQueryLog();
     $AllBrands = $Brands->getAll();
     $BrandList = [];
     foreach ($AllBrands as $brand) {
         $BrandList[$brand->id] = $brand->brand->name . ' ' . $brand->name;
     }
     //echo '<pre>';print_r($BrandList);exit;
     $AllCategories = $Category->getAll();
     $vehicle = $ModelVehicle->view($id, 0);
     $vehicleFeatures = $vehicle->features()->lists('feature_id', 'feature_id')->toArray();
     //
     /* Breadcrumbs */
     $title = "Edit Vehicle";
     $this->page->getBody()->addBreadcrumb('Vehicle', '/admin/vehicle');
     $this->page->getBody()->addBreadcrumb($vehicle->name, admin_route('vehicle.show', $vehicle->id));
     $this->page->getBody()->addBreadcrumb('Edit');
     /* Breadcrumbs */
     /* Page Maker */
     $this->page->getHead()->setDescription('add area');
     $this->page->getHead()->setKeywords('manage, edit, area, manage area, edit area');
     $this->page->setTitle($title);
     $this->page->getBody()->addToData('Brands', $BrandList);
     $this->page->getBody()->addToData('Categories', $AllCategories);
     $this->page->getBody()->addToData('Vehicle', $vehicle);
     $this->page->getBody()->addToData('FeatureCategory', $FeatureCategory);
     $this->page->getBody()->addToData('vehicleFeatures', $vehicleFeatures);
     $this->page->getBody()->addToData('tab', $tab);
     return view($this->viewBase . "." . __FUNCTION__, array('page' => $this->page));
 }