-
app/Models/Channel/Comment.php
Open in GitHubuse 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 GitHubuse 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) ]); } }