Run composer update
Feb 23, 2022
7
Level 1
Call to undefined method Illuminate\Database\Eloquent\Casts\Attribute::make() On Laravel 9
After trying to create an Accessor in Larvel 9 i get this error:Call to undefined method Illuminate\Database\Eloquent\Casts\Attribute::make().
My code:
<?php
namespace Modules\Protocol\Entities;
use Illuminate\Database\Eloquent\Casts\Attribute;
use DateTime;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
class Protocol extends Model
{
use HasFactory;
protected $fillable = ['document_type', 'description_id', 'subject', 'employee_name', 'date_recived_sent', 'sender_id', 'sender_document_ref', 'subId', 'userId', 'department_id'];
protected $with = ['contact', 'department'];
public function contact() {
return $this->hasOne('Modules\Contact\Entities\Contact', 'id', 'sender_id');
}
public function department() {
return $this->belongsTo('Modules\Department\Entities\Department', 'department_id', 'id');
}
/**
*
*
* @return \Illuminate\Database\Eloquent\Casts\Attribute
*/
protected function PrettySRDate(): Attribute {
return Attribute::make(
get: fn () => (new DateTime($this->date_recived_sent))->format('d.m.Y')
);
}
protected static function newFactory()
{
return \Modules\Protocol\Database\factories\ProtocolFactory::new();
}
}
Please or to participate in this conversation.