FavoriteController   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
c 0
b 0
f 0
lcom 0
cbo 3
dl 0
loc 23
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A store() 0 10 1
A destroy() 0 9 1
1
<?php
2
/**
3
 * GitScrum v0.1.
4
 *
5
 * @author  Renato Marinho <[email protected]>
6
 * @license http://opensource.org/licenses/GPL-3.0 GPLv3
7
 */
8
9
namespace GitScrum\Http\Controllers;
10
11
use GitScrum\Models\Favorite;
12
13
class FavoriteController extends Controller
14
{
15
    public function store($type, $id)
16
    {
17
        $data = [
18
            'favoriteable_id' => $id,
19
            'favoriteable_type' => $type,
20
        ];
21
        Favorite::create($data);
22
23
        return back()->with('success', trans('Favorited successfully'));
24
    }
25
26
    public function destroy($type, $id)
27
    {
28
        $favorite = Favorite::where('favoriteable_id', $id)
29
            ->where('favoriteable_type', $type)->userActive()->first();
30
31
        $favorite->delete();
32
33
        return back()->with('success', trans('Unfavorited successfully'));
34
    }
35
}
36