BNav.php
1.3 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
65
66
67
68
69
70
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\SoftDeletes;
/**
* b端控制, c端显示的导航
* @author:dc
* @time 2023/5/8 16:14
* Class BNav
* @package App\Models
*/
class BNav extends Base
{
protected $table = 'gl_web_nav';
use SoftDeletes;
public $hidden = ['deleted_at','project_id'];
/**
* 显示
*/
const STATUS_ACTIVE = 1;
/**
* 隐藏
*/
const STATUS_DISABLED = 0;
/**
* 查询当前项目下的所有栏目信息
* @param int $project_id
* @return mixed
* @author:dc
* @time 2023/5/8 16:29
*/
public static function _all(int $project_id, string $location = null)
{
return static::where(function ($query) use ($project_id,$location){
// 那个公司
$query->where('project_id',$project_id);
// 显示位置
$location && $query->where('location',$location);
})
->orderBy('sort')
->get();
}
/**
* 是否有下级
* @param int $id
* @param int $project_id
* @return mixed
* @author:dc
* @time 2023/5/9 9:23
*/
public static function isChild(int $id,int $project_id=0)
{
return static::where(['pid'=>$id,'project_id'=>$project_id])->limit(1)->count();
}
}