コード例 #1
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $sheet = new Sheet($request->all());
     $sheet->save();
     foreach ($sheet->quest->questions as $question) {
         $answer = $sheet->answers()->create(['question_id' => $question->id]);
     }
     return Redirect::route('users.sheets', $request->user_id);
 }
コード例 #2
0
ファイル: UpVote.php プロジェクト: RedrockTeam/jukebox
 /**
  * Handle a job failure.
  *
  * @return void
  */
 public function failed()
 {
     // Called when the job is failing...
     $this->redis->hDel('jk_upvote:' . $this->sheet->getAttributeValue('song_id') . ':userLIST', $this->sheet->getAttributeValue('user_id'));
 }
コード例 #3
0
 /**
  * 显示未采纳的歌曲列表(资源未上传)
  */
 public function songList()
 {
     return response()->json(['page' => 1, 'perPage' => 10, 'list' => Sheet::getRecentlyFailedSongSheets()], 200, ['Access-Control-Allow-Origin' => '*']);
 }
コード例 #4
0
 /**
  * 获取当前用户发布的歌单
  *
  * @param Request           $request
  * @param string|integer    $user_id
  * @return array
  */
 private function obtainSongsListPublishedByUser($request, $user_id)
 {
     $publishByUser = \App\Sheet::getCurrentUserPublishedSheets($user_id);
     return is_null($publishByUser) ? $this->emptyLists : $publishByUser;
 }
コード例 #5
0
 /**
  * 用户想听当前歌曲
  *
  * @param Request $request
  *
  * @return string
  */
 public function like(Request $request)
 {
     // 得到指定的ID的歌单
     $sheet = Sheet::where('song_id', $request->get('id'))->first();
     // 得到当前用户的ID
     $user = $request->session()->get('jukebox_user', null);
     // 用于验证唯一会话
     $key = $request->get('id') . '|' . $user;
     // 如果尝试次数不超过3
     if (!app(RateLimiter::class)->tooManyAttempts($key, 3, 5)) {
         app(RateLimiter::class)->hit($key);
     } else {
         return json_encode(['status' => 0]);
     }
     if (is_null($user)) {
         abort(403);
     }
     return $this->promiseUserLike($sheet, $user);
 }