Menu.php
1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
namespace App\Models\Manage;
use App\Models\Base;
use Illuminate\Support\Facades\Cache;
class Menu extends Base
{
protected $table = 'gl_manage_menu';
const STATUS_NORMAL = 0;
const STATUS_ABNORMAL = 1;
const TYPE_SHOW = 'show';
const TYPE_SAVE = 'save';
const TYPE_DELETE = 'delete';
/**
* @return string[]
*/
public static function statusMap(): array
{
return [
self::STATUS_NORMAL => '正常',
self::STATUS_ABNORMAL => '禁用',
];
}
/**
* @return string[]
*/
public static function typeMap(): array
{
return [
self::TYPE_SHOW => '查看',
self::TYPE_SAVE => '保存',
self::TYPE_DELETE => '删除',
];
}
/**
* @param $route_name
* @return mixed
* @author zbj
* @date 2023/4/25
*/
public static function getByRouteName($route_name){
$cache_key = 'manage_menu_'.$route_name;
$data = Cache::get($cache_key);
if(!$data){
$data = self::where('route_name', $route_name)->first();
if($data){
Cache::put($cache_key, $data);
}
}
return $data;
}
public static function clearCache($row){
$cache_key = 'manage_menu_' . $row->original['route_name'];
Cache::forget($cache_key);
}
}