1
I have the model below and when I do a search that has data, it works right, but when it does not have it returns null, it was not to return the class of the empty model, without filling in the data?
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class AreaInteresse extends Model
{
use HasFactory;
protected $table = 'ZPVOBJETIVOINTERESSE';
protected $fillable = [
'cpf',
'nivel',
'area',
];
}
I’m doing the research like this:
$areasInteresse = AreaInteresse::where('cpf', '=', Auth::user()->cpf)->orderBy('id', 'asc')->get();
Could you tell me what you’re going to use this data for? Why couldn’t the return be null? By default when no data returns null even, it is correct!
– Paulo Martins