get(); return view('Staff.chat.bot.index', [ 'bots' => $bots, ]); } /** * Show the form for editing the specified Bot resource. * * @param \Illuminate\Http\Request $request * @param int $id * * @return \Illuminate\Http\Response */ public function edit(Request $request, $id) { $user = $request->user(); $bot = Bot::findOrFail($id); return view('Staff.chat.bot.edit', [ 'user' => $user, 'bot' => $bot, ]); } /** * Update the specified Bot resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { $user = $request->user(); $bot = Bot::findOrFail($id); if ($request->has('command') && $request->input('command') == $bot->command) { $v = validator($request->all(), [ 'name' => 'required|min:3|max:255', 'command' => 'required|alpha_dash|min:3|max:255', 'position' => 'required', 'color' => 'required', 'icon' => 'required', 'emoji' => 'required', 'help' => 'sometimes|max:9999', 'info' => 'sometimes|max:9999', 'about' => 'sometimes|max:9999', ]); } else { $v = validator($request->all(), [ 'name' => 'required|min:3|max:255', 'command' => 'required|alpha_dash|min:3|max:255|unique:bots', 'position' => 'required', 'color' => 'required', 'icon' => 'required', 'emoji' => 'required', 'help' => 'sometimes|max:9999', 'info' => 'sometimes|max:9999', 'about' => 'sometimes|max:9999', ]); } $error = null; $success = null; $redirect = null; if ($v->passes()) { $bot->name = $request->input('name'); $bot->slug = Str::slug($request->input('name')); $bot->position = $request->input('position'); $bot->color = $request->input('color'); $bot->icon = $request->input('icon'); $bot->emoji = $request->input('emoji'); $bot->about = $request->input('about'); $bot->info = $request->input('info'); $bot->help = $request->input('help'); $bot->command = $request->input('command'); $bot->save(); $success = 'The Bot Has Been Updated'; } if (! $success) { $error = 'Unable To Process Request'; if ($v->errors()) { $error = $v->errors(); } return redirect()->route('staff.bots.edit', ['id' => $id]) ->withErrors($error); } return redirect()->route('staff.bots.edit', ['id' => $id]) ->withSuccess($success); } /** * Remove the specified Bot resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $bot = Bot::where('is_protected', '=', 0)->findOrFail($id); $bot->delete(); return redirect()->route('staff.bots.index') ->withSuccess('The Humans Vs Machines War Has Begun! Humans: 1 and Bots: 0'); } /** * Disable the specified Bot resource in storage. * * @param int $id * @return \Illuminate\Http\Response */ public function disable($id) { $bot = Bot::findOrFail($id); $bot->active = 0; $bot->save(); return redirect()->route('staff.bots.index') ->withSuccess('The Bot Has Been Disabled'); } /** * Enable the specified Bot resource in storage. * * @param int $id * @return \Illuminate\Http\Response */ public function enable($id) { $bot = Bot::findOrFail($id); $bot->active = 1; $bot->save(); return redirect()->route('staff.bots.index') ->withSuccess('The Bot Has Been Enabled'); } }