forked from w33b/hstream
Init
This commit is contained in:
34
app/Livewire/Watched.php
Normal file
34
app/Livewire/Watched.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use App\Models\Watched as UserWatched;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Livewire\Component;
|
||||
use Livewire\WithPagination;
|
||||
|
||||
class Watched extends Component
|
||||
{
|
||||
use WithPagination;
|
||||
|
||||
public $userId;
|
||||
|
||||
public function mount($user)
|
||||
{
|
||||
$this->userId = $user ? $user->id : auth()->user()->id;
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
$watched = UserWatched::where('user_id', $this->userId)->orderBy('created_at', 'desc')->paginate(25);
|
||||
$watchedGrouped = $watched->groupBy(function ($val) {
|
||||
return Carbon::parse($val->created_at)->format('h');
|
||||
});
|
||||
|
||||
return view('livewire.watched', [
|
||||
'watched' => $watched,
|
||||
'watchedGrouped' => $watchedGrouped,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user