public function links() { if (null == $this->links) { $this->links = Links::query()->where('linkable_type = :type:', ['type' => get_class($this)])->andWhere('linkable_id = :id:', ['id' => $this->id])->execute(); } return $this->links; }
public function getLinksInfo() { if (null == $this->linksInfo) { $this->linksInfo = Links::query()->leftJoin('Movies', 'Links.linkable_id = Movies.id AND Links.linkable_type = "Movies"')->where('site_id = :site_id:', ['site_id' => $this->id])->columns(['Links.id', 'Links.url', 'Links.note', 'Links.linkable_id AS movie_id', 'Links.created_at', 'Movies.title'])->orderBy('Links.updated_at DESC')->execute(); } return $this->linksInfo; }
public function links() { if (null == $this->links) { $this->links = Links::query()->where('user_id = :user:'******'user' => $this->id])->leftJoin('Movies', 'Movies.id = Links.movie_id')->leftJoin('Sites', 'Sites.id = Links.site_id')->columns(['Links.id', 'Links.url', 'Links.created_at', 'Links.user_id', 'Sites.name AS siteName', 'Sites.id AS siteId', 'Movies.title AS movieTitle', 'Movies.id AS movieId'])->orderBy('Links.created_at DESC')->execute(); } return $this->links; }