 9a6f1788a4
			
		
	
	9a6f1788a4
	
	
	
		
			
			PHP 5.5.9 adds the new static `class` property which provides the fully qualified class name. This is preferred over using strings for class names since the `class` property references are checked by PHP.
		
			
				
	
	
		
			73 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			73 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| 
 | |
| namespace App\Model\helpdesk\Form;
 | |
| 
 | |
| use App\BaseModel;
 | |
| 
 | |
| class Forms extends BaseModel
 | |
| {
 | |
|     protected $table = 'custom_forms';
 | |
| 
 | |
|     /**
 | |
|      * The attributes that are mass assignable.
 | |
|      *
 | |
|      * @var array
 | |
|      */
 | |
|     protected $fillable = ['formname'];
 | |
| 
 | |
|     public function fieldRelation()
 | |
|     {
 | |
|         $related = \App\Model\helpdesk\Form\Fields::class;
 | |
| 
 | |
|         return $this->hasMany($related);
 | |
|     }
 | |
| 
 | |
|     public function fields()
 | |
|     {
 | |
|         $relation = $this->fieldRelation()->get();
 | |
| 
 | |
|         return $relation;
 | |
|     }
 | |
| 
 | |
|     public function fieldsDelete()
 | |
|     {
 | |
|         $fields = $this->fields();
 | |
|         if ($fields->count() > 0) {
 | |
|             foreach ($fields as $field) {
 | |
|                 $field->delete();
 | |
|             }
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     public function formValueRelation()
 | |
|     {
 | |
|         $related = \App\Model\helpdesk\Form\FieldValue::class;
 | |
| 
 | |
|         return $this->hasMany($related, 'child_id');
 | |
|     }
 | |
| 
 | |
|     public function formValueChild()
 | |
|     {
 | |
|         $childs = $this->formValueRelation()->get();
 | |
| 
 | |
|         return $childs;
 | |
|     }
 | |
| 
 | |
|     public function deleteFormChild()
 | |
|     {
 | |
|         $childs = $this->formValueChild();
 | |
|         if ($childs->count() > 0) {
 | |
|             foreach ($childs as $child) {
 | |
|                 $child->child_id = null;
 | |
|                 $child->save();
 | |
|             }
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     public function delete()
 | |
|     {
 | |
|         $this->fieldsDelete();
 | |
|         parent::delete();
 | |
|     }
 | |
| }
 |