Skip to content

Commit cb36ee8

Browse files
committed
Initial commit
0 parents  commit cb36ee8

32 files changed

+1176
-0
lines changed

Config/config.php

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
return [
4+
'name' => 'Ftp'
5+
];
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
use Illuminate\Support\Facades\Schema;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Database\Migrations\Migration;
6+
7+
class CreateFtpCommandsTable extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*
12+
* @return void
13+
*/
14+
public function up()
15+
{
16+
Schema::create('ftp_commands', function (Blueprint $table) {
17+
$table->increments('id');
18+
$table->integer('ds_id')->unique()->unsigned();
19+
$table->string('default_host')->nullable();
20+
$table->string('create_command')->nullable();
21+
$table->string('update_command')->nullable();
22+
$table->string('delete_command')->nullable();
23+
$table->timestamps();
24+
25+
$table->foreign('ds_id')->references('id')->on('dedicated_servers')->onDelete('cascade');
26+
});
27+
}
28+
29+
/**
30+
* Reverse the migrations.
31+
*
32+
* @return void
33+
*/
34+
public function down()
35+
{
36+
Schema::dropIfExists('ftp_commands');
37+
}
38+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
use Illuminate\Support\Facades\Schema;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Database\Migrations\Migration;
6+
7+
class CreateFtpAccountsTable extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*
12+
* @return void
13+
*/
14+
public function up()
15+
{
16+
Schema::create('ftp_accounts', function (Blueprint $table) {
17+
$table->increments('id');
18+
$table->integer('ds_id')->unsigned();
19+
$table->integer('user_id')->unsigned()->nullable();
20+
$table->string('host');
21+
$table->integer('port')->nullable();
22+
$table->string('username');
23+
$table->string('password');
24+
$table->string('dir');
25+
$table->timestamps();
26+
27+
$table->foreign('ds_id')->references('id')->on('dedicated_servers')->onDelete('cascade');
28+
$table->foreign('user_id')->references('id')->on('users')->onDelete('set null');
29+
});
30+
}
31+
32+
/**
33+
* Reverse the migrations.
34+
*
35+
* @return void
36+
*/
37+
public function down()
38+
{
39+
Schema::dropIfExists('ftp_accounts');
40+
}
41+
}
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
namespace GameapModules\Ftp\Database\Seeders;
4+
5+
use Illuminate\Database\Seeder;
6+
use Illuminate\Database\Eloquent\Model;
7+
8+
class FtpDatabaseSeeder extends Seeder
9+
{
10+
/**
11+
* Run the database seeds.
12+
*
13+
* @return void
14+
*/
15+
public function run()
16+
{
17+
Model::unguard();
18+
19+
// $this->call("OthersTableSeeder");
20+
}
21+
}
+122
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
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+
}
+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?php
2+
3+
namespace GameapModules\Ftp\Http\Controllers;
4+
5+
use Illuminate\Http\Request;
6+
use Illuminate\Http\Response;
7+
use Gameap\Http\Controllers\AuthController;
8+
use Gameap\Models\DedicatedServer;
9+
use GameapModules\Ftp\Models\FtpCommand;
10+
use GameapModules\Ftp\Http\Requests\FtpCommandRequest;
11+
use GameapModules\Ftp\Repositories\FtpCommandRepository;
12+
13+
class FtpCommandsController extends AuthController
14+
{
15+
/**
16+
* The GameRepository instance.
17+
*
18+
* @var \GameapModules\Ftp\Repositories\FtpCommandRepository
19+
*/
20+
protected $repository;
21+
22+
/**
23+
* Create a new GameController instance.
24+
*
25+
* @param \GameapModules\Ftp\Repositories\FtpCommandRepository $repository
26+
*/
27+
public function __construct(FtpCommandRepository $repository)
28+
{
29+
parent::__construct();
30+
31+
$this->repository = $repository;
32+
}
33+
34+
/**
35+
* Show the form for editing the specified resource.
36+
* @param int $id
37+
* @return Response
38+
*/
39+
public function edit()
40+
{
41+
$ftpCommands = FtpCommand::all()->keyBy('ds_id');
42+
43+
return view('ftp::ftp_commands.edit', [
44+
'ftpCommands' => $ftpCommands,
45+
'dedicatedServers' => DedicatedServer::all(),
46+
]);
47+
}
48+
49+
/**
50+
* Update the specified resource in storage.
51+
* @param FtpCommandRequest $request
52+
* @param int $id
53+
* @return Response
54+
*/
55+
public function update(FtpCommandRequest $request)
56+
{
57+
$this->repository->updateAll($request->all());
58+
59+
return redirect()->route('admin.ftp')
60+
->with('success', 'Updated');
61+
}
62+
}

Http/Controllers/FtpController.php

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
namespace GameapModules\Ftp\Http\Controllers;
4+
5+
use Illuminate\Http\Request;
6+
use Illuminate\Http\Response;
7+
use Gameap\Http\Controllers\AuthController;
8+
use GameapModules\Ftp\Models\FtpAccount;
9+
10+
class FtpController extends AuthController
11+
{
12+
/**
13+
* Display a listing of the resource.
14+
* @return Response
15+
*/
16+
public function index()
17+
{
18+
return view('ftp::index', [
19+
'ftpAccounts' => FtpAccount::paginate(20)
20+
]);
21+
}
22+
}

Http/Middleware/.gitkeep

Whitespace-only changes.

Http/Requests/FtpAccountRequest.php

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
namespace GameapModules\Ftp\Http\Requests;
4+
5+
use Gameap\Http\Requests\Request;
6+
7+
class FtpAccountRequest extends Request
8+
{
9+
public function rules()
10+
{
11+
return [
12+
'ds_id' => 'exists:dedicated_servers,id',
13+
'user_id' => 'exists:users,id',
14+
'host' => 'required',
15+
'port' => 'integer',
16+
'username' => 'required',
17+
'password' => 'required',
18+
'dir' => 'required'
19+
];
20+
}
21+
}

Http/Requests/FtpCommandRequest.php

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
/**
3+
* Created by PhpStorm.
4+
* User: nikita
5+
* Date: 4/21/19
6+
* Time: 4:06 PM
7+
*/
8+
9+
namespace GameapModules\Ftp\Http\Requests;
10+
11+
use Gameap\Http\Requests\Request;
12+
13+
class FtpCommandRequest extends Request
14+
{
15+
public function rules()
16+
{
17+
return [
18+
'default_host.*' => '',
19+
'create_command.*' => '',
20+
'update_command.*' => '',
21+
'delete_command.*' => '',
22+
];
23+
}
24+
}

0 commit comments

Comments
 (0)