我在Laravel文档中看到了创建访问器的示例,但我不理解"get"单词后面的冒号的含义:
链接到页面:https://laravel.com/docs/9.x/eloquent-mutators#defining-an-accessor
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Model;
class User extends Model
{
/**
* Get the user's first name.
*
* @return \Illuminate\Database\Eloquent\Casts\Attribute
*/
protected function firstName(): Attribute
{
return Attribute::make(
get: fn ($value) => ucfirst($value),
);
}
}