public firstOrCreate ( array $data ) : static | ||
$data | array | Data for the newly created item |
return | static |
public function firstOrCreate($data)
{
$item = $this->get(true, 0, 1)->first();
if (is_null($item)) {
$item = clone $this;
$item->create($data);
}
return $item;
}