MessageController::detail()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 9
c 0
b 0
f 0
nc 2
nop 1
dl 0
loc 15
rs 9.9666
1
<?php
2
3
namespace App\Http\Controllers;
4
5
use App\Models\Eloquent\Message;
6
use Auth;
7
use Illuminate\Support\Facades\Redirect;
8
9
class MessageController extends Controller
10
{
11
    public function index()
12
    {
13
        return view('message.index', [
14
            'page_title' => "Message",
15
            'site_title' => config("app.name"),
16
            'navigation' => "Home",
17
            'messages' => Message::listAll(Auth::user()->id),
0 ignored issues
show
Bug introduced by
Accessing id on the interface Illuminate\Contracts\Auth\Authenticatable suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
18
        ]);
19
    }
20
21
    public function detail($id)
22
    {
23
        $message = Message::find($id);
24
25
        if (blank($message) || $message->receiver != Auth::user()->id) {
0 ignored issues
show
Bug introduced by
Accessing id on the interface Illuminate\Contracts\Auth\Authenticatable suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
26
            return Redirect::route('message.index');
27
        }
28
29
        $message->read();
30
31
        return view('message.detail', [
32
            'page_title'=>"Message",
33
            'site_title'=>config("app.name"),
34
            'navigation'=>"Home",
35
            'message' => $message
36
        ]);
37
    }
38
}
39