/** * Save the number of times a video is viewed. * * @param \Illuminate\Http\Request * @return \Illuminate\Http\Response */ public function viewCount(Request $request) { if (isset($request->id)) { $video = Videos::find($request->id); $video->play = is_null($video->play) ? 1 : $video->play + 1; $video->save(); return new Response($video->play, 200); } }
/** * Test videos are paginated. * * @return void */ public function testVideosPaginated() { factory(Soma\Videos::class, 24)->create(); $results = Videos::paginate(6); $this->assertEquals(6, $results->perPage()); }