Issues (166)

app/Http/Controllers/ServicesController.php (7 issues)

1
<?php
2
3
namespace App\Http\Controllers;
4
5
use Illuminate\Http\Request;
6
use Auth;
7
use App\Service;
8
use App\Http\Requests;
9
use App\Http\Controllers\Controller;
10
use Lubus\Constants\Status;
0 ignored issues
show
The type Lubus\Constants\Status was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
12
class ServicesController extends Controller
13
{
14
    public function __construct()
15
    {
16
        $this->middleware('auth');
17
    }
18
	/**
19
     * Display a listing of the resource.
20
     *
21
     * @return Response
0 ignored issues
show
The type App\Http\Controllers\Response was not found. Did you mean Response? If so, make sure to prefix the type with \.
Loading history...
22
     */
23
     public function index(Request $request)
24
     {
25
        $services = Service::search('"'.$request->input('search').'"')->paginate(10);
26
        $serviceTotal = Service::search('"'.$request->input('search').'"')->get();
27
        $count = $serviceTotal->count();
28
29
    	return view('services.index', compact('services','count'));
0 ignored issues
show
Bug Best Practice introduced by
The expression return view('services.in...t('services', 'count')) returns the type Illuminate\View\View which is incompatible with the documented return type App\Http\Controllers\Response.
Loading history...
30
     }
31
32
     /**
33
     * Display the specified resource.
34
     *
35
     * @param  int  $id
36
     * @return Response
37
     */
38
    public function show()
39
    {
40
    	$service = Service::findOrFail($id);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $id seems to be never defined.
Loading history...
41
42
    	return view('services.show', compact('service'));
0 ignored issues
show
Bug Best Practice introduced by
The expression return view('services.show', compact('service')) returns the type Illuminate\View\View which is incompatible with the documented return type App\Http\Controllers\Response.
Loading history...
43
    }
44
45
     /**
46
     * Show the form for creating a new resource.
47
     *
48
     * @return Response
49
     */
50
    public function create()
51
    {
52
    	return view('services.create');
0 ignored issues
show
Bug Best Practice introduced by
The expression return view('services.create') returns the type Illuminate\View\View which is incompatible with the documented return type App\Http\Controllers\Response.
Loading history...
53
    }
54
    
55
     /**
56
     * Store a newly created resource in storage.
57
     *
58
     * @return Response
59
     */
60
    public function store(Request $request)
61
    {
62
        //Model Validation
63
        $this->validate($request, ['name' => 'unique:mst_services,name']);
64
65
        $service = new Service($request->all());
66
67
        $service->createdBy()->associate(Auth::user());
68
        $service->updatedBy()->associate(Auth::user());
69
70
        $service->save();
71
72
        flash()->success('Service was successfully created');
73
74
    	return redirect('plans/services/all'); 
0 ignored issues
show
Bug Best Practice introduced by
The expression return redirect('plans/services/all') returns the type Illuminate\Http\Redirect...nate\Routing\Redirector which is incompatible with the documented return type App\Http\Controllers\Response.
Loading history...
75
    }
76
77
    public function edit($id)
78
    {
79
        $service = Service::findOrFail($id);
80
81
        return view('services.edit', compact('service'));
82
    }
83
84
    public function update($id, Request $request)
85
    {
86
87
        $service = Service::findOrFail($id);
88
89
        $service->update($request->all());
90
        $service->updatedBy()->associate(Auth::user());
91
        $service->save();
92
        flash()->success('Service details were successfully updated');
93
        return redirect('plans/services/all');
94
    }
95
96
    public function delete($id)
97
    {
98
        Service::destroy($id);
99
100
        return redirect('plans/services/all');
101
    }
102
}
103