/**
  * Guarda el nuevo banner
  *
  * @param  AdvertisementRequest  $request -> valida los campos que son requeridos para crear un nuevo banner
  * @return \Illuminate\Http\Response
  */
 public function store(AdvertisementRequest $request)
 {
     /* equivale al query insert  */
     /* $request->all() trae los datos que pusimos en nuestra forma */
     Advertisement::create($request->all());
     /* redirige al listado de banners */
     return redirect('advertisements');
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(AdvertisementRequest $request)
 {
     $input = $request->except("_token");
     $validator = Validator::make($input, ['name' => 'required|min:3', 'phone' => 'required|min:0', 'email' => 'required|email']);
     if ($validator->fails()) {
         return redirect('advertise')->withErrors($validator)->withInput();
     }
     $status = $this->repo->create($input);
     return redirect('advertise')->with('success', "Thank You We Will Contact You.");
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  int $id
  * @return Response
  */
 public function update(Advertisement $advertisement, AdvertisementRequest $request)
 {
     $advertisement->update($request->input());
     return redirect()->route('admin.advertisement.index');
 }
Beispiel #4
0
 /**
  * Insert advertisement to database
  */
 public function flush(AdvertisementRequest $request)
 {
     // flag top = 0 into all ads, and flag = 1 in last ad
     $ads_top = Advertisement::where('top', '=', 1)->get();
     foreach ($ads_top as $at) {
         $at->top = 0;
         $at->update();
     }
     $hash = Session::get('advertisements_hash');
     $attachmentsNames = AdsAttachment::where('hash', $hash)->get()->toArray();
     $ads = new Advertisement();
     $ads->fill($request->all());
     $ads->user_id = Auth::user()->id;
     $ads->city_id = Auth::user()->profile->city_id;
     $ads->attachment_hash = $hash;
     $ads->top = 1;
     $ads->save();
     Session::forget('advertisements_hash');
     foreach ($attachmentsNames as $attachments => $attachment) {
         AdsAttachment::where('id', $attachment['id'])->update(['comment' => Input::get($attachment['id'])]);
     }
     return Redirect::to('/');
 }