public function streamer($bannerStreamId) { $bannerStream = BannerStream::findOrFail($bannerStreamId); $banner = $bannerStream->banner; $stream = $bannerStream->stream; $client = $banner->client; StreamMapper::pay($client, $banner, $stream); LogMapper::log('banner_paid', $banner->id, $stream->id); LogMapper::log('decline_resolve', $banner->id, $stream->id, ['resolution' => 'streamer wins']); NotificationMapper::bannerPayAccept($banner, $stream, $bannerStream->amount); return redirect('/admin/decline')->with(['success' => 'You accepted streamer\'s point of view']); }
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']); }
public function declineSave($streamId, $bannerId, Request $request) { $stream = Stream::findOrFail($streamId); $banner = Banner::findOrFail($bannerId); if (!StreamMapper::checkOwner($this->user, $banner, $stream)) { return Redirect::to('/user/client/streams')->withErrors('You have no rights for this'); } if ($stream->time_end == null) { return Redirect::to('/user/client/stream/' . $stream->id)->withErrors('Stream is still live'); } $pivot = StreamMapper::getPivot($banner, $stream); if ($pivot->status != 'waiting') { return Redirect::to('/user/client/stream/' . $stream->id)->withErrors('Stream is not for paying'); } $isFinished = $this->isStreamFinished($stream); if (!$isFinished) { return Redirect::to('/user/client/stream/' . $stream->id)->withErrors('Stream is still alive'); } $this->validate($request, ['comment' => 'required|min:5']); $comment = $request->get('comment'); $pivot->status = 'declining'; $pivot->client_comment = $comment; $pivot->save(); LogMapper::log('banner_declining', $banner->id, $stream->id); NotificationMapper::bannerPayDeclining($banner, $stream, $pivot->amount); return Redirect::to('/user/client/stream/' . $stream->id)->with(['success' => 'You declined to pay the banner in this stream']); }
public function payStreams() { $bannerStreams = BannerStream::whereStatus('waiting')->get(); $faker = $this->faker; foreach ($bannerStreams as $bs) { $skip = boolval(rand(0, 1)); if ($skip) { continue; } $banner = $bs->banner; $user = $banner->client; $stream = $bs->stream; $transfer = StreamMapper::pay($user, $banner, $stream); $decline = rand(0, 5); if ($decline == 4) { $bs->status = 'declining'; $bs->client_comment = $faker->paragraph; $bs->save(); LogMapper::log('banner_declining', $banner->id, $stream->id); NotificationMapper::bannerPayDeclining($banner, $stream, $bs->amount); } else { $bs->status = 'accepted'; $bs->save(); LogMapper::log('banner_paid', $banner->id, $stream->id); NotificationMapper::bannerPayAccept($banner, $stream, $bs->amount); } } }