I have a table leads, and a model Lead, inside the model I have a getter and setter for a certain attribute, however, it's not working.
using dd(1); inside shows that the function is never called.
why?
Model:
class Lead extends Model
{
use HasFactory;
// The name of the field in the database is `lead_image_alt`.
public function getLeadImageAltAttribute($value)
{
// dd(1); // never executed
return "Some text";
}
public function setLeadImageAltAttribute($value)
{
// dd(1); // never executed
$this->attributes['lead_image_alt'] = "Some text";
}
}
Controller:
public function edit(Lead $lead)
{
return view('leads.edit', ['lead' => $lead]);
}