Hello,
How can I access a Model's properties in a Controller in Laravel?
In my User model I have this array:
protected $sortable = [
'first_name',
'last_name',
'email',
];
and I created a getter:
public function getSortable()
{
return $this->sortable;
}
Then, in my UserController I have:
namespace App\Http\Controllers;
...
use App\User;
class UserController extends Controller
{
public function index()
{
// here I'd like to get the $sortable array
}
}
Thank you
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community