-2
I’m trying to bring the data to a view to perform some tests on Laravel but it’s not working
Controller
class ProfileController extends Controller
{
private $aluno;
private $request;
public function __construct(Aluno $aluno, Request $request)
{
$this->aluno = $aluno;
$this->request = $request;
}
public function index()
{
$id = '39';
$alunos = $this->aluno
->select('*')
->where('id', '=', $id)
->get();
return view('profile.index', compact('alunos'));
}
Model
<?php
namespace App\Models\Profile;
use Illuminate\Database\Eloquent\Model;
class Aluno extends Model
{
protected $table = 'aluno';
}
You have a variable
$alunos
and in the Compact is onlyaluno
, what’s the mistake?– rray
Excuse was typo error the error that brings is this Undefined Property: Illuminate Database Eloquent Collection::$name (View: C: xampp htdocs course Resources profile index.blade.php)
– Shaolin Fantastic
Put the model in
– rray
I put the Model
– Shaolin Fantastic