我只是通过laravel tutrorial去网上,我看到下面的模态编码如下:了解在laravel型号静态方法
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Notice extends Model {
protected $fillable = [
'provider_id',
'infringing_title',
'infringing_link',
'original_link',
'original_description',
'template',
'content_removed'
];
public static function open(array $attributes) {
return new static($attributes);
}
public function useTemplate($template) {
$this->template = $template;
}
}
什么,我想知道到底是什么是利用以下被定义的方法:
public static function open(array $attributes) {
return new static($attributes);
}
我意识到它是一个静态方法,但此行return new static($attributes);
特别是混淆了我。
我看到下面的方式使用方法:
$notice = Notice::open($date);
但我还是不太了解它的用法。有人可以解释。