<?php
namespace App\Http\Controllers\DJ;
use App\Http\Controllers\Controller;
use App\Models\DJSays;
use App\Models\User;
use Illuminate\Http\Request;
class DJSaysController extends Controller
{
public function getForm()
{
$says = DJSays::remember(5)->orderBy('id', 'desc')->take(1)->first();
return view('dj.dj-says', ['current' => $says ? e($says->msg) : _('Currently unset.')]);
}
public function postForm(Request $request)
{
$this->validate($request, [
'msg' => 'required|string|max:200'
], [], ['msg' => _('DJ Says')]);
$says = new DJSays;
$says->dj = auth()->user()->userid;
$says->msg = $request->get('msg');
$says->save();
return redirect()->back()->with('msg', [
'type' => 'success',
'msg' => _('Successfully updated the DJ Says, this change has been reflected on the main site.')
]);
}
public function getSays()
{
$says = DJSays::remember(5)->orderBy('id', 'desc')->take(1)->first();
if ($says) {
return ['dj' => User::remember(30)->find($says->dj)->username, 'msg' => e($says->msg)];
} else {
return ['dj' => _('Unavailable'), 'msg' => _('Currently unset.')];
}
}
}