コード例 #1
0
ファイル: AdController.php プロジェクト: zedx/core
 /**
  * Update the specified resource in storage.
  *
  * @param int $id
  *
  * @return Response
  */
 public function update(Ad $ad, AdRequest $request)
 {
     $this->restoreIfTrashed($ad);
     $oldStatus = $ad->adstatus->title;
     $geo = new GeolocationHelper($request->get('geolocation_data'));
     $user = User::findOrFail($request->get('user_id'));
     $category = Category::findOrFail($request->get('category_id'));
     $ad->user()->associate($user);
     $ad->category()->associate($category);
     $ad->geolocation->fill($geo->get());
     $ad->content->fill($request->get('content'));
     $ad->price = $this->getPrice($ad, $request);
     event(new AdWillBeUpdated($ad, $this->admin));
     $ad->save();
     $ad->geolocation->save();
     $ad->content->save();
     if ($ad->adtype->can_update_pic) {
         $this->syncAdPhotos($ad, $request);
     }
     if ($ad->adtype->can_update_video) {
         $this->syncAdVideos($ad, $request);
     }
     $this->syncAdFields($ad, $request);
     if ($oldStatus != 'pending') {
         event(new AdWasUpdated($ad, $this->admin));
     }
     return redirect()->route('zxadmin.ad.edit', $ad->id);
 }
コード例 #2
0
ファイル: CategoryController.php プロジェクト: zedx/core
 /**
  * Order the specified resource in storage.
  *
  * @param int $id
  *
  * @return Response
  */
 public function order(Category $category)
 {
     if ($left_id = Request::get('leftId')) {
         $cat_left = Category::findOrFail($left_id);
         $category->moveToRightOf($cat_left);
     } elseif ($right_id = Request::get('rightId')) {
         $cat_right = Category::findOrFail($right_id);
         $category->moveToLeftOf($cat_right);
     } elseif ($parent_id = Request::get('parentId')) {
         $cat_parent = Category::findOrFail($parent_id);
         $category->makeChildOf($cat_parent);
     }
 }