You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
			
				
					44 lines
				
				667 B
			
		
		
			
		
	
	
					44 lines
				
				667 B
			| 
								 
											7 years ago
										 
									 | 
							
								<?php
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * Created by Error202
							 | 
						||
| 
								 | 
							
								 * Date: 09.07.2018
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								namespace core\entities\menu;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								use yii\db\ActiveRecord;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * Class Menu
							 | 
						||
| 
								 | 
							
								 * @package core\entities
							 | 
						||
| 
								 | 
							
								 *
							 | 
						||
| 
								 | 
							
								 * @property integer $id
							 | 
						||
| 
								 | 
							
								 * @property string $name
							 | 
						||
| 
								 | 
							
								 *
							 | 
						||
| 
								 | 
							
								 * @property MenuItem[] $items
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								class Menu extends ActiveRecord
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
									public static function create($name): self
							 | 
						||
| 
								 | 
							
									{
							 | 
						||
| 
								 | 
							
										$menu = new static();
							 | 
						||
| 
								 | 
							
										$menu->name = $name;
							 | 
						||
| 
								 | 
							
										return $menu;
							 | 
						||
| 
								 | 
							
									}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
									public function edit($name): void
							 | 
						||
| 
								 | 
							
									{
							 | 
						||
| 
								 | 
							
										$this->name = $name;
							 | 
						||
| 
								 | 
							
									}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
									public static function tableName(): string
							 | 
						||
| 
								 | 
							
									{
							 | 
						||
| 
								 | 
							
										return '{{%menu}}';
							 | 
						||
| 
								 | 
							
									}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
									public function getItems()
							 | 
						||
| 
								 | 
							
									{
							 | 
						||
| 
								 | 
							
										return $this->hasMany(MenuItem::class, ['menu_id' => 'id'])->orderBy(['sort' => SORT_ASC]);
							 | 
						||
| 
								 | 
							
									}
							 | 
						||
| 
								 | 
							
								}
							 |