FavoriteController::store()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 2
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