*/ class DJSaysController extends Controller { /** * Get the form to change the DJ Says. * * @return mixed */ 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.')]); } /** * Change the DJ Says that is shown on the main site. * * @param Request $request * @return mixed */ 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.') ]); } /** * API method call. Allow the frontend site to get the current DJ Says. * * @return array */ public function getSays() { $says = DJSays::remember(5)->orderBy('id', 'desc')->take(1)->first(); if ($says) { return ['dj' => User::remember(30)->find($says->dj)->getDisplayName()->toHtml(), 'msg' => e($says->msg)]; } else { return ['dj' => _('Unavailable'), 'msg' => _('Currently unset.')]; } } }