Issue with laravel eloquent model property



PHP Snippet 1:

@foreach($calendar as $day)
    {{$day->date}}
    <br>
@endforeach

PHP Snippet 2:

2022-03-01

PHP Snippet 3:

class Calendar extends Model
{
    use HasFactory;

    protected $primaryKey = 'date';
    protected $keyType = 'string';

    public function advanceprograms(){
        return $this->belongsToMany(AdvanceProgram::class, 'advance_program_calendar', 'date', 'advance_program_id');
    }
}

PHP Snippet 4:

class Calendar extends Model
{
    use HasFactory;

    protected $primaryKey = 'date';
    protected $keyType = 'date';

    public function advanceprograms(){
        return $this->belongsToMany(AdvanceProgram::class, 'advance_program_calendar', 'date', 'advance_program_id');
    }
}

PHP Snippet 5:

@foreach($calendar as $day)
    {{$day->date->format('d-m-Y')}}
    <br>
@endforeach

PHP Snippet 6:

protected $primaryKey = 'date';
public $incrementing = false;   // no auto increment
public $timestamps = false;     // if there are not timestamp table