feat: paginate workshops and videos pages
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Video;
|
||||
use App\Models\VideoView;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class VideoViewController extends Controller
|
||||
{
|
||||
public function store(Video $video) {
|
||||
$user = auth()->user();
|
||||
|
||||
//firstOrCreate só cria se não existir, se existir, atualiza o watched_at
|
||||
VideoView::firstOrCreate([
|
||||
'user_id' => $user->id,
|
||||
'video_id' => $video->id,
|
||||
], [
|
||||
'watched_at' => now(),
|
||||
]);
|
||||
|
||||
return response()->json(['watched' => true]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user