L
L
lynnikvadim2016-03-26 20:41:00
Laravel
lynnikvadim, 2016-03-26 20:41:00

Using a Model in a Laravel Controller?

How can use App\Model;you call a model in a controller without being able to?
$name=App\Model::find($k)->pluck('name');
This does not work. Or did I write it wrong?
Thank you.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vyacheslav Plisko, 2016-03-27
@lynnikvadim

It's better to use use.
And so you lost \, because the name is determined from the current App\Http\Controllers namespace,
you need \App\Model

M
Muhammad, 2016-03-26
@muhammad_97

Model:find($k)->pluck('name');

A
Andrzej Wielski, 2016-03-26
@wielski

Connect the model with use
use App\Model;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question