AdminCreatorController::show()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 1
nc 1
nop 1
1
<?php
2
3
namespace App\Http\Controllers;
4
5
use Illuminate\Http\Request;
6
7
use App\Http\Requests;
8
use App\Creator;
9
use Illuminate\Support\Facades\Session;
10
11
class AdminCreatorController extends Controller
12
{
13
    /**
14
     * Display a listing of the resource.
15
     *
16
     * @return \Illuminate\Http\Response
17
     */
18
    public function index()
19
    {
20
      $creators = Creator::all();
21
        return view('Admin.creators.index',compact('creators'));
22
    }
23
24
    /**
25
     * Show the form for creating a new resource.
26
     *
27
     * @return \Illuminate\Http\Response
28
     */
29
    public function create()
30
    {
31
        //
32
    }
33
34
    /**
35
     * Store a newly created resource in storage.
36
     *
37
     * @param  \Illuminate\Http\Request  $request
38
     * @return \Illuminate\Http\Response
39
     */
40
    public function store(Request $request)
0 ignored issues
show
Unused Code introduced by
The parameter $request is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
41
    {
42
        //
43
    }
44
45
    /**
46
     * Display the specified resource.
47
     *
48
     * @param  int  $id
49
     * @return \Illuminate\Http\Response
50
     */
51
    public function show($id)
0 ignored issues
show
Unused Code introduced by
The parameter $id is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
52
    {
53
        //
54
    }
55
56
    /**
57
     * Show the form for editing the specified resource.
58
     *
59
     * @param  int  $id
60
     * @return \Illuminate\Http\Response
61
     */
62
    public function edit($id)
63
    {
64
      $creator = Creator::find($id);
65
      $creators = Creator::all();
66
        return view('Admin.creators.edit',compact('creator','creators'));
67
    }
68
69
    /**
70
     * Update the specified resource in storage.
71
     *
72
     * @param  \Illuminate\Http\Request  $request
73
     * @param  int  $id
74
     * @return \Illuminate\Http\Response
75
     */
76
    public function update(Request $request, $id)
77
    {
78
        Creator::updateOrCreate(['id'=>$id],[
0 ignored issues
show
Bug introduced by
The method updateOrCreate() does not exist on App\Creator. Did you maybe mean create()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
79
            'postcode' => $request['postcode'],
80
            'country' => $request['country'],
81
            'home_address' => $request['home_address'],
82
        ]);
83
        Session::flash('message','Successfully updated');
84
        return redirect(url('creators'));
0 ignored issues
show
Bug introduced by
It seems like url('creators') targeting url() can also be of type object<Illuminate\Contracts\Routing\UrlGenerator>; however, redirect() does only seem to accept string|null, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
85
    }
86
87
    /**
88
     * Remove the specified resource from storage.
89
     *
90
     * @param  int  $id
91
     * @return \Illuminate\Http\Response
92
     */
93
    public function destroy($id)
94
    {
95
       Creator::destroy($id);
96
97
        Session::flash('message','Successfully deleted');
98
        return redirect(url('creators'));
0 ignored issues
show
Bug introduced by
It seems like url('creators') targeting url() can also be of type object<Illuminate\Contracts\Routing\UrlGenerator>; however, redirect() does only seem to accept string|null, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
99
    }
100
}
101