Пример #1
0
 protected function createAd($adtype, $data)
 {
     $geo = new Geolocation($data['geolocation_data']);
     $adstatus = Adstatus::whereTitle('pending')->first();
     $ad = new Ad();
     $ad->user_id = $data['user_id'];
     $ad->category_id = $data['category_id'];
     $ad->adstatus()->associate($adstatus);
     $ad->adtype()->associate($adtype);
     $ad->save();
     $ad->geolocation()->create($geo->get());
     $ad->content()->create($data['content']);
     if ($ad->adtype->can_add_pic) {
         $this->syncAdPhotos($ad, $data);
     }
     if ($ad->adtype->can_add_video) {
         $this->syncAdVideos($ad, $data);
     }
     $this->syncAdFields($ad, $data);
     event(new AdWasCreated($ad, 'ZEDx'));
     $this->validateAd($ad);
 }
Пример #2
0
 /**
  * Remove the specified resource from storage.
  *
  * @param Ad $ad
  *
  * @return Response
  */
 protected function destroy(Ad $ad, $forceDelete)
 {
     $adstatus = Adstatus::whereTitle('trashed')->first();
     $ad->adstatus()->associate($adstatus);
     $ad->save();
     event(new AdWillBeDeleted($ad, $this->admin, $forceDelete));
     if ($forceDelete) {
         $ad->forceDelete();
     } else {
         $ad->delete();
     }
     event(new AdWasDeleted($ad, $this->admin, $forceDelete));
 }
Пример #3
0
 /**
  * Remove the specified resource from storage.
  *
  * @param Ad $ad
  *
  * @return Response
  */
 public function destroy(Ad $ad)
 {
     $adstatus = Adstatus::whereTitle('trashed')->first();
     $ad->adstatus()->associate($adstatus);
     $ad->save();
     event(new AdWillBeDeleted($ad, $this->user));
     $ad->delete();
     event(new AdWasDeleted($ad, $this->user));
 }