mysql - Create Eloquent model from complex raw SQL-query -
i thinking right design of method gives user list of clients who's last appointment long time ago. so have 2 table (simplified): clients (id, first_name) appointments (id, client_id, datetime) what trying do: list of 3 clients who's last appointment long time ago. so do: select users oldest appointments , return them (with complex sql query). create models them. is design case? use illuminate\database\eloquent\collection; class clientrepository { /** * clients no appointments in near history (sort date of last appointment asc) * * @todo make better way find falling clients (more laravelish maybe?) * @param $count how many clients should method return * @return illuminate\database\eloquent\collection */ static public function getlost($count=3) { //this sql looks long works charm //solution based on http://stackoverflow.com/questions/1066453/mysql-group-by-and-order-by $sql = " s...