Cart   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
eloc 6
c 1
b 0
f 1
dl 0
loc 13
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A emptyCart() 0 2 1
A user() 0 2 1
1
<?php
2
3
4
namespace Mongi\Mongicommerce\Models;
5
6
7
use Illuminate\Support\Facades\Auth;
8
use Illuminate\Database\Eloquent\Model;
9
use Illuminate\Database\Eloquent\Factories\HasFactory;
10
11
class Cart extends Model
12
{
13
    use HasFactory;
14
    protected $table = 'cart';
15
    protected $dates = ["created_at","updated_at"];
16
17
18
    public function user(){
19
        return $this->belongsTo(User::class,'user_id');
20
    }
21
22
    static function emptyCart(){
23
        self::where('user_id',Auth::user()->id)->delete();
0 ignored issues
show
Bug introduced by
Accessing id on the interface Illuminate\Contracts\Auth\Authenticatable suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
24
    }
25
26
27
}
28