Пример #1
0
 public function complainDeclineSave($streamId, $bannerId, Request $request)
 {
     $stream = Stream::findOrFail($streamId);
     $banner = Banner::findOrFail($bannerId);
     if ($stream->user_id != $this->user->id) {
         return Redirect::to('/user/twitcher/streams')->withErrors('You have no rights for this');
     }
     $pivot = StreamMapper::getPivot($banner, $stream);
     if ($pivot->status != 'declining') {
         return Redirect::to('/user/twitcher/stream/' . $stream->id)->withErrors('Stream is not declining');
     }
     $this->validate($request, ['comment' => 'required|min:5']);
     $comment = $request->get('comment');
     $pivot->status = 'complain';
     $pivot->twitcher_comment = $comment;
     $pivot->save();
     LogMapper::log('banner_complained', $banner->id, $stream->id);
     NotificationMapper::bannerPayComplained($banner, $stream, $pivot->amount);
     return Redirect::to('/user/twitcher/stream/' . $stream->id)->with(['success' => 'You complained about banner declined']);
 }