feat : menu list

This commit is contained in:
2024-10-28 11:55:57 +08:00
parent b828d48672
commit c86c6c1baf
6 changed files with 322 additions and 16 deletions

View File

@@ -5,7 +5,9 @@ declare(strict_types=1);
namespace App\Model;
use App\Constants\Admin\AuthCode;
use Hyperf\Database\Model\Builder;
use Hyperf\DbConnection\Model\Model;
use Hyperf\Tappable\HigherOrderTapProxy;
/**
* @property int $id
@@ -49,6 +51,30 @@ class AdminMenu extends Model
*/
public function getAllMenu(): array
{
return $this->where('status', AuthCode::MENU_STATUS_ENABLE)->orderBy('sort', 'desc')->get()->toArray();
return $this
->where('status', AuthCode::MENU_STATUS_ENABLE)
->orderBy('sort', 'desc')
->get()
->toArray();
}
/**
* @param int $url
* @return Builder|\Hyperf\Database\Model\Model|null
*/
public function getMenuByUrl(int $url): \Hyperf\Database\Model\Model|Builder|null
{
return $this
->where('url', $url)
->first();
}
/**
* @param int $id
* @return HigherOrderTapProxy|mixed|null
*/
public function getChildMenuType(int $id)
{
return $this->where('parent_id', $id)->value('type');
}
}