['except' => ''], 'typeFilter' => ['except' => 'all'], 'tag' => ['except' => ''], 'author' => ['except' => ''] ]; public function render() { if ($this->author) { $author = $this->author; $user = User::find($author); $posts = $user ? $user->author_of_blog_post()->distinct() : []; } elseif($this->tag) { $tagId = Str::of($this->tag)->split('/-/')->first(); $posts = Tag::find($tagId)->blogPosts(); } elseif ($this->search && mb_strlen($this->search) > 2) { $posts = BlogPost::where('title', 'rlike', $this->search); } else { $posts = (new BlogPost); } if($this->typeFilter == 'user') { $posts = $posts->whereRelation('author', 'is_consultant', false); } if ($this->typeFilter == 'consultant') { $posts = $posts->whereRelation('author', 'is_consultant', true); } return view('livewire.blog-post.list-view', ['blogPosts' => $posts->orderBy('created_at', 'desc')->paginate(10)]); } }