CheckPermissionTrait::checkPermission()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 3
rs 10
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: guoliang
5
 * Date: 2019/3/11
6
 * Time: 上午10:17.
7
 */
8
9
namespace Modules\Core\Traits\Repository;
10
11
trait CheckPermissionTrait
12
{
13
    /**
14
     * 检查权限.
15
     *
16
     * @param \Illuminate\Foundation\Auth\User $user
17
     * @param int                              $id
18
     *
19
     * @return bool
20
     */
21
    public function checkPermission($user, int $id)
22
    {
23
        return $this->model->where(['id' => $id, 'user_id' => $user->id])->exists();
24
    }
25
}
26