|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace GameapModules\Ftp\Http\Controllers; |
| 4 | + |
| 5 | +use Illuminate\Http\Response; |
| 6 | +use Gameap\Http\Controllers\AuthController; |
| 7 | +use Gameap\Models\DedicatedServer; |
| 8 | +use GameapModules\Ftp\Repositories\FtpAccountRepository; |
| 9 | +use GameapModules\Ftp\Models\FtpAccount; |
| 10 | +use GameapModules\Ftp\Http\Requests\FtpAccountRequest; |
| 11 | + |
| 12 | +class FtpAccountsController extends AuthController |
| 13 | +{ |
| 14 | + /** |
| 15 | + * The GameRepository instance. |
| 16 | + * |
| 17 | + * @var \GameapModules\Ftp\Repositories\FtpAccountRepository |
| 18 | + */ |
| 19 | + protected $repository; |
| 20 | + |
| 21 | + /** |
| 22 | + * Create a new GameController instance. |
| 23 | + * |
| 24 | + * @param \GameapModules\Ftp\Repositories\FtpAccountRepository $repository |
| 25 | + */ |
| 26 | + public function __construct(FtpAccountRepository $repository) |
| 27 | + { |
| 28 | + parent::__construct(); |
| 29 | + |
| 30 | + $this->repository = $repository; |
| 31 | + } |
| 32 | + |
| 33 | + /** |
| 34 | + * Display a listing of the resource. |
| 35 | + * @return Response |
| 36 | + */ |
| 37 | + public function index() |
| 38 | + { |
| 39 | + return view('ftp::ftp_accounts.list', [ |
| 40 | + 'ftpAccounts' => FtpAccount::paginate(20) |
| 41 | + ]); |
| 42 | + } |
| 43 | + |
| 44 | + /** |
| 45 | + * Show the form for creating a new resource. |
| 46 | + * @return Response |
| 47 | + */ |
| 48 | + public function create() |
| 49 | + { |
| 50 | + return view('ftp::ftp_accounts.create', [ |
| 51 | + 'dedicatedServers' => DedicatedServer::all()->pluck('name', 'id'), |
| 52 | + ]); |
| 53 | + } |
| 54 | + |
| 55 | + /** |
| 56 | + * Store a newly created resource in storage. |
| 57 | + * |
| 58 | + * @param FtpAccountRequest $request |
| 59 | + * @return Response |
| 60 | + */ |
| 61 | + public function store(FtpAccountRequest $request) |
| 62 | + { |
| 63 | + $this->repository->store($request->all()); |
| 64 | + |
| 65 | + return redirect()->route('admin.ftp.accounts.index') |
| 66 | + ->with('success', 'Created'); |
| 67 | + } |
| 68 | + |
| 69 | + /** |
| 70 | + * Show the specified resource. |
| 71 | + * |
| 72 | + * @param int $id |
| 73 | + * @return Response |
| 74 | + */ |
| 75 | + // public function show($id) |
| 76 | + // { |
| 77 | + // return view('ftp::ftp_accounts.show'); |
| 78 | + // } |
| 79 | + |
| 80 | + /** |
| 81 | + * Show the form for editing the specified resource. |
| 82 | + * |
| 83 | + * @param int $id |
| 84 | + * @return Response |
| 85 | + */ |
| 86 | + public function edit(FtpAccount $ftpAccount) |
| 87 | + { |
| 88 | + return view('ftp::ftp_accounts.edit', [ |
| 89 | + 'ftpAccount' => $ftpAccount |
| 90 | + ]); |
| 91 | + } |
| 92 | + |
| 93 | + /** |
| 94 | + * Update the specified resource in storage. |
| 95 | + * |
| 96 | + * @param FtpAccountRequest $request |
| 97 | + * @param int $id |
| 98 | + * @return Response |
| 99 | + */ |
| 100 | + public function update(FtpAccountRequest $request, $id) |
| 101 | + { |
| 102 | + $this->repository->update($id, $request->all()); |
| 103 | + |
| 104 | + return redirect()->route('admin.ftp') |
| 105 | + ->with('success', 'Updated'); |
| 106 | + } |
| 107 | + |
| 108 | + /** |
| 109 | + * Remove the specified resource from storage. |
| 110 | + * |
| 111 | + * @param FtpAccount $ftpAccount |
| 112 | + * @return \Illuminate\Http\RedirectResponse |
| 113 | + * @throws \Exception |
| 114 | + */ |
| 115 | + public function destroy(FtpAccount $ftpAccount) |
| 116 | + { |
| 117 | + $this->repository->destroy($ftpAccount); |
| 118 | + |
| 119 | + return redirect()->route('admin.ftp.accounts.index') |
| 120 | + ->with('success', 'Deleted'); |
| 121 | + } |
| 122 | +} |
0 commit comments