/** * Get Total Rating */ public function getRatingAttribute() { return MovieRating::select(DB::raw('SUM(rating) AS rating'))->where('movie_id', $this->id)->first()->rating; }