FOF30\Model\DataModel::firstOrCreate PHP Méthode

firstOrCreate() public méthode

Return the first item found or create a new one based on the provided $data
public firstOrCreate ( array $data ) : static
$data array Data for the newly created item
Résultat static
    public function firstOrCreate($data)
    {
        $item = $this->get(true, 0, 1)->first();
        if (is_null($item)) {
            $item = clone $this;
            $item->create($data);
        }
        return $item;
    }