I just went through the laravel online survey and I saw the following modal code as shown below:
<?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;
}
}
What I'm interested in knowing is how exactly the method described below is used:
public static function open(array $attributes) {
return new static($attributes);
}
I understand its static method, but this line return new static($attributes);especially bothers me.
I see that the method is used as follows:
$notice = Notice::open($date);
But I still do not quite understand its use. can someone explain.
source
share