<?php namespace App\Repositories; use App\User; class UserRepository extends Repository { protected $model; public function __construct(User $model) { $this->model = $model; } public function get($with = null) { return $this->model ->when($with, function ($query) use ($with) { return $query->with($with); }) ->orderBy('name', 'asc') ->get(); } }