ShoutboxController::store()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 18
rs 9.4285
cc 1
eloc 11
nc 1
nop 1
1
<?php
2
3
/*
4
 * rmarchiv.tk
5
 * (c) 2016-2017 by Marcel 'ryg' Hering
6
 */
7
8
namespace App\Http\Controllers;
9
10
use Carbon\Carbon;
11
use App\Events\Obyx;
12
use App\Models\Shoutbox;
13
use Illuminate\Http\Request;
14
15
class ShoutboxController extends Controller
16
{
17
    public function store(Request $request)
18
    {
19
        $this->validate($request, [
20
            'shout' => 'required',
21
        ]);
22
23
        \DB::table('shoutbox')
24
            ->insert([
25
                'shout_md'   => $request->get('shout'),
26
                'shout_html' => \Markdown::convertToHtml($request->get('shout')),
27
                'user_id'    => \Auth::id(),
28
                'created_at' => Carbon::now(),
29
            ]);
30
31
        event(new Obyx('shoutbox', \Auth::id()));
32
33
        return redirect()->route('home');
34
    }
35
36
    public function index()
37
    {
38
        $shoutbox = Shoutbox::with('user')->orderBy('created_at', 'desc')->paginate(25);
39
40
        return view('shoutbox.index', [
41
            'shoutbox' => $shoutbox,
42
        ]);
43
    }
44
}
45