数据表:
model:一级菜单类进行一对多关联
<?php
namespace app\pc\model;
use think\Model;
class FirstLevelMenus extends Model
{
protected $table = 'first_level_menus';
protected $pk = 'menu_id';
public function secondMenus()
{
return $this->hasMany(SecondLevelMenus::class,'parent_menu_tag','menu_tag');
}
}
model/二级菜单空模型
<?php
namespace app\pc\model;
use think\Model;
class SecondLevelMenus extends Model{
protected $table = 'second_level_menus';
protected $pk = 'menu_id';
}
在index调用
<?php
declare(strict_types=1);
namespace app\pc\controller;
use app\pc\model\FirstLevelMenus;
class Index
{
public f