openstamanager/src/Models/Checklist/ChecklistItem.php

44 lines
903 B
PHP
Raw Normal View History

2019-07-26 18:05:19 +02:00
<?php
namespace Models\Checklist;
use Common\Model;
use Traits\HierarchyTrait;
class Checklist extends Model
{
use HierarchyTrait;
protected static $parent_identifier = 'id_parent';
protected $table = 'zz_checklist_items';
/**
* Crea un nuovo elemento della checklist.
*
* @param Checklist $checklist
* @param string $contenuto
* @param int $id_parent
*
* @return self
*/
public static function build(Checklist $checklist, $contenuto, $id_parent = null)
{
$model = parent::build();
$model->checklist()->associate($checklist);
$model->id_parent = $id_parent;
$model->content = $contenuto;
$model->save();
return $model;
}
/* Relazioni Eloquent */
public function checklist()
{
return $this->belongsTo(Checklist::class, 'id_checklist');
}
}