Issues (42)

src/InboxController.php (13 issues)

1
<?php
2
3
namespace Evilnet\Inbox;
4
use Evilnet\Inbox\Controller;
5
use Evilnet\Inbox\Services\InboxService;
6
use Illuminate\Http\Request;
0 ignored issues
show
The type Illuminate\Http\Request 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...
7
8
class InboxController extends Controller
9
{
10
11
    protected $inboxService;
12
13
    public function __construct(InboxService $inboxService)
14
    {
15
        $this->inboxService = $inboxService;
16
    }
17
18
    /**
19
     * Display a listing of the resource.
20
     *
21
     * @return \Illuminate\Http\Response
0 ignored issues
show
The type Illuminate\Http\Response 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...
22
     */
23
    public function index()
24
    {
25
        $conversations = $this->inboxService->fetchAllConversation();
26
27
      $users = $this->inboxService->getInboxUsers($conversations);
28
29
30
     return view('inbox::inbox.index', compact('conversations', 'users'));
0 ignored issues
show
The function view was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

30
     return /** @scrutinizer ignore-call */ view('inbox::inbox.index', compact('conversations', 'users'));
Loading history...
31
    }
32
    /**
33
     * Show the form for creating a new resource.
34
     *
35
     * @return \Illuminate\Http\Response
36
     */
37
    public function create()
38
    {
39
        return view('inbox::inbox.create');
0 ignored issues
show
The function view was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

39
        return /** @scrutinizer ignore-call */ view('inbox::inbox.create');
Loading history...
40
    }
41
42
    /**
43
     * Store a newly created resource in storage.
44
     *
45
     * @param  \Illuminate\Http\Request  $request
46
     * @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\Response
0 ignored issues
show
The type Illuminate\Http\RedirectResponse 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...
47
     */
48
    public function store(Request $request)
49
    {
50
        $this->validate($request,
51
            [
52
                'user' => 'required',
53
                'message' => 'required|max:10000',
54
                'subject' => 'required'
55
            ]
56
            );
57
        $this->inboxService->addConversation($request->get('user'), $request->get('message'), $request->get('subject'));
58
    }
59
60
    /**
61
     * Display the specified resource.
62
     *
63
     * @param conversation|int $id
64
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
0 ignored issues
show
The type Illuminate\View\View 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...
65
     */
66
    public function show(Conversation $id)
67
    {
68
        if(auth()->id() == $id->id_to OR auth()->id() == $id->id_from) {
0 ignored issues
show
The function auth was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

68
        if(/** @scrutinizer ignore-call */ auth()->id() == $id->id_to OR auth()->id() == $id->id_from) {
Loading history...
69
            return view('inbox::inbox.show')->with('conversation', $id);
0 ignored issues
show
The function view was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

69
            return /** @scrutinizer ignore-call */ view('inbox::inbox.show')->with('conversation', $id);
Loading history...
70
        }
71
        return redirect()->back();
0 ignored issues
show
The function redirect was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

71
        return /** @scrutinizer ignore-call */ redirect()->back();
Loading history...
72
73
    }
74
75
    /**
76
     * Update the specified resource in storage.
77
     *
78
     * @param  \Illuminate\Http\Request $request
79
     * @param conversation|int $id
80
     * @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\Response
81
     */
82
    public function addMessage(Request $request, Conversation $id)
83
    {
84
        $this->validate($request,
85
            [
86
                'message' => 'required|max:10000'
87
            ]
88
        );
89
        if(auth()->id() == $id->id_to OR auth()->id() == $id->id_from) {
0 ignored issues
show
The function auth was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

89
        if(/** @scrutinizer ignore-call */ auth()->id() == $id->id_to OR auth()->id() == $id->id_from) {
Loading history...
90
91
            $this->inboxService->addMessage($request, $id);
92
        }
93
        return redirect()->back();
0 ignored issues
show
The function redirect was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

93
        return /** @scrutinizer ignore-call */ redirect()->back();
Loading history...
94
95
    }
96
    /**
97
     * Remove the specified resource from storage.
98
     *
99
     * @param  int  $id
100
     * @return \Illuminate\Http\Response
101
     */
102
    public function destroy(Conversation $id)
103
    {
104
        if(auth()->id() == $id->id_to OR auth()->id() == $id->id_from) {
0 ignored issues
show
The function auth was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

104
        if(/** @scrutinizer ignore-call */ auth()->id() == $id->id_to OR auth()->id() == $id->id_from) {
Loading history...
105
106
            $this->inboxService->deleteConversation($id);
107
        }
108
        return redirect()->back();
0 ignored issues
show
The function redirect was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

108
        return /** @scrutinizer ignore-call */ redirect()->back();
Loading history...
109
110
    }
111
}
112