Passed
Push — master ( b831b6...96f132 )
by John
06:04 queued 21s
created

DojoPass::user()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 1
b 0
f 1
1
<?php
2
3
namespace App\Models\Eloquent\Dojo;
4
5
use Illuminate\Database\Eloquent\Model;
6
use Illuminate\Database\Eloquent\SoftDeletes;
7
use Auth;
8
9
class DojoPass extends Model
10
{
11
    use SoftDeletes;
12
13
    protected $fillable=[
14
        'dojo_id', 'user_id'
15
    ];
16
17
    public function dojo()
18
    {
19
        return $this->belongsTo('App\Models\Eloquent\Dojo\Dojo', 'dojo_id');
20
    }
21
22
    public function user()
23
    {
24
        return $this->belongsTo('App\Models\Eloquent\UserModel', 'user_id');
25
    }
26
27
    public static function isPassed($dojo_id)
28
    {
29
        return Auth::check()?self::where([
30
            "dojo_id"=>$dojo_id,
31
            "user_id"=>Auth::user()->id,
32
        ])->count()>0:false;
33
    }
34
}
35