Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
class Index extends Controller
{
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
$models = MyModel::all();
return View('index', compact('models'));
}
}
Read documentation laravel.com/docs/5.1/controllers#dependency-inject...
// инъекция в конструктор
public function __construct(User $users) {
$this->users = $users;
}
public function index() {
return $this->user->all();
}
// инъекция прямо в метод
public function index(User $users) {
return $users->all();
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question