Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

PHPJunior/mtube

144 stars
2 code files
View PHPJunior/mtube on GitHub

app/Models/Channel/Comment.php

Open in GitHub
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
 
class Comment extends Model
{
public function scopeParent($query)
{
return $query->where('parent_id', null);
}
}

app/Http/Livewire/Frontend/Components/Comment.php

Open in GitHub
use App\Events\DynamicChannel;
use App\Models\Channel\Video;
use Livewire\Component;
use Livewire\WithPagination;
 
class Comment extends Component
{
use WithPagination;
 
public $video;
public $perPage = 5;
//
public function mount()
{
$this->getData();
}
//
public function getData()
{
$this->video = Video::find($this->video_id);
}
 
public function render()
{
return view('livewire.frontend.components.comment')->with([
'comments' => $this->video->comments()->parent()->where('hide', false)->orderBy('created_at', 'desc')->paginate($this->perPage)
]);
}
}

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.