public function delete(Request $request)
 {
     //locations to be deleted
     $data = [];
     //check for single delete
     if (isset($request->id)) {
         $data[] = $request->id;
     }
     //check for mass delete if no single delete
     if (empty($data)) {
         $data = $request->input('ad_condition_id');
     }
     //delete
     if (!empty($data)) {
         AdCondition::destroy($data);
         //clear cache, set message, redirect to list
         Cache::flush();
         session()->flash('message', trans('admin_common.Ad Condition deleted'));
         return redirect(url('admin/adcondition'));
     }
     //nothing for deletion set message and redirect
     session()->flash('message', trans('admin_common.Nothing for deletion'));
     return redirect(url('admin/adcondition'));
 }
Пример #2
0
 public function edit(Request $request)
 {
     //get ad id
     $ad_id = $request->id;
     //get ad info
     $ad_detail = $this->ad->getAdDetail($ad_id, 0);
     $ad_detail->ad_price_type_1 = $ad_detail->ad_price_type_2 = $ad_detail->ad_price_type_3 = $ad_detail->ad_price;
     $ad_detail->condition_id_type_1 = $ad_detail->condition_id_type_3 = $ad_detail->condition_id;
     $ad_detail->ad_description = Util::br2nl($ad_detail->ad_description);
     //get ad pics
     $ad_pic = AdPic::where('ad_id', $ad_id)->get();
     $car_model_id = array();
     if (old('car_brand_id')) {
         if (is_numeric(old('car_brand_id')) && old('car_brand_id') > 0) {
             $car_models = CarModel::where('car_brand_id', old('car_brand_id'))->orderBy('car_model_name', 'asc')->get();
             if (!$car_models->isEmpty()) {
                 $car_model_id = array(0 => 'Select Car Model');
                 foreach ($car_models as $k => $v) {
                     $car_model_id[$v->car_model_id] = $v->car_model_name;
                 }
             }
         }
     }
     $ad_detail->ad_category_info = $this->category->getParentsByIdFlat($ad_detail->category_id);
     $ad_detail->pics = AdPic::where('ad_id', $ad_detail->ad_id)->get();
     return view('admin.ad.ad_edit', ['ad_detail' => $ad_detail, 'ad_pic' => $ad_pic, 'c' => $this->category->getAllHierarhy(), 'l' => $this->location->getAllHierarhy(), 'at' => AdType::all(), 'ac' => AdCondition::all(), 'estate_construction_type' => EstateConstructionType::all(), 'estate_furnishing_type' => EstateFurnishingType::all(), 'estate_heating_type' => EstateHeatingType::all(), 'estate_type' => EstateType::all(), 'car_brand_id' => CarBrand::all(), 'car_model_id' => $car_model_id, 'car_engine_id' => CarEngine::all(), 'car_transmission_id' => CarTransmission::all(), 'car_condition_id' => CarCondition::all(), 'car_modification_id' => CarModification::all()]);
 }