diff --git a/.env.example b/.env.example
index d8afcdd8..30eb1afe 100644
--- a/.env.example
+++ b/.env.example
@@ -12,5 +12,3 @@ DB_USERNAME=
DB_PASSWORD=
CACHE_DRIVER=array
-SESSION_DRIVER=array
-QUEUE_DRIVER=sync
diff --git a/Makefile b/Makefile
index 73e8a6d3..52d6370f 100644
--- a/Makefile
+++ b/Makefile
@@ -10,24 +10,30 @@ all: build
build:
composer install --no-interaction
+ php artisan optimize
+ php artisan config:cache
@make db
-install:
+install: db
echo ""
+reset:
+ @rm database/testing.sqlite
+ @php artisan optimize
+ @php artisan config:clear
+ @sqlite3 database/testing.sqlite ""
+ @php artisan migrate:refresh --seed
+
db:
sqlite3 database/testing.sqlite ""
php artisan migrate
+ php artisan db:seed
unittest-db:
rm -f database/unittest.sqlite
sqlite3 database/unittest.sqlite ""
php artisan migrate:refresh --seed --env unittest
-reset-db:
- rm database/testing.sqlite
- make db
-
tests: test
test:
@@ -35,7 +41,7 @@ test:
schema:
#php artisan infyom:scaffold Airlines --fieldsFile=database/schema/airlines.json
- php artisan infyom:scaffold Aircraft --fieldsFile=database/schema/aircraft.json
+ #php artisan infyom:scaffold Aircraft --fieldsFile=database/schema/aircraft.json
echo ""
docker:
diff --git a/README.md b/README.md
index 050b412c..5d60e6d8 100755
--- a/README.md
+++ b/README.md
@@ -13,6 +13,7 @@ run the following commands. for right now, we're running on sqlite. for mysql, s
```bash
cp .env.example .env
composer install --no-interaction
+php artisan optimize
sqlite3 database/testing.sqlite ""
php artisan migrate:refresh --seed
```
diff --git a/app/Http/Controllers/Admin/AirportController.php b/app/Http/Controllers/Admin/AirportController.php
new file mode 100644
index 00000000..f39b0591
--- /dev/null
+++ b/app/Http/Controllers/Admin/AirportController.php
@@ -0,0 +1,156 @@
+airportRepository = $airportRepo;
+ }
+
+ /**
+ * Display a listing of the Airport.
+ *
+ * @param Request $request
+ * @return Response
+ */
+ public function index(Request $request)
+ {
+ $this->airportRepository->pushCriteria(new RequestCriteria($request));
+ $airports = $this->airportRepository->all();
+
+ return view('admin.airports.index')
+ ->with('airports', $airports);
+ }
+
+ /**
+ * Show the form for creating a new Airport.
+ *
+ * @return Response
+ */
+ public function create()
+ {
+ return view('admin.airports.create');
+ }
+
+ /**
+ * Store a newly created Airport in storage.
+ *
+ * @param CreateAirportRequest $request
+ *
+ * @return Response
+ */
+ public function store(CreateAirportRequest $request)
+ {
+ $input = $request->all();
+
+ $airport = $this->airportRepository->create($input);
+
+ Flash::success('Airport saved successfully.');
+
+ return redirect(route('admin.airports.index'));
+ }
+
+ /**
+ * Display the specified Airport.
+ *
+ * @param int $id
+ *
+ * @return Response
+ */
+ public function show($id)
+ {
+ $airport = $this->airportRepository->findWithoutFail($id);
+
+ if (empty($airport)) {
+ Flash::error('Airport not found');
+
+ return redirect(route('admin.airports.index'));
+ }
+
+ return view('admin.airports.show')->with('airport', $airport);
+ }
+
+ /**
+ * Show the form for editing the specified Airport.
+ *
+ * @param int $id
+ *
+ * @return Response
+ */
+ public function edit($id)
+ {
+ $airport = $this->airportRepository->findWithoutFail($id);
+
+ if (empty($airport)) {
+ Flash::error('Airport not found');
+
+ return redirect(route('admin.airports.index'));
+ }
+
+ return view('admin.airports.edit')->with('airport', $airport);
+ }
+
+ /**
+ * Update the specified Airport in storage.
+ *
+ * @param int $id
+ * @param UpdateAirportRequest $request
+ *
+ * @return Response
+ */
+ public function update($id, UpdateAirportRequest $request)
+ {
+ $airport = $this->airportRepository->findWithoutFail($id);
+
+ if (empty($airport)) {
+ Flash::error('Airport not found');
+
+ return redirect(route('admin.airports.index'));
+ }
+
+ $airport = $this->airportRepository->update($request->all(), $id);
+
+ Flash::success('Airport updated successfully.');
+
+ return redirect(route('admin.airports.index'));
+ }
+
+ /**
+ * Remove the specified Airport from storage.
+ *
+ * @param int $id
+ *
+ * @return Response
+ */
+ public function destroy($id)
+ {
+ $airport = $this->airportRepository->findWithoutFail($id);
+
+ if (empty($airport)) {
+ Flash::error('Airport not found');
+
+ return redirect(route('admin.airports.index'));
+ }
+
+ $this->airportRepository->delete($id);
+
+ Flash::success('Airport deleted successfully.');
+
+ return redirect(route('admin.airports.index'));
+ }
+}
diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php
index 34c376cf..750a4d59 100755
--- a/app/Http/Controllers/Auth/RegisterController.php
+++ b/app/Http/Controllers/Auth/RegisterController.php
@@ -2,8 +2,9 @@
namespace App\Http\Controllers\Auth;
-use App\User;
use Validator;
+use App\Models\Role;
+use App\Models\User;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\RegistersUsers;
@@ -50,7 +51,7 @@ class RegisterController extends Controller
return Validator::make($data, [
'name' => 'required|max:255',
'email' => 'required|email|max:255|unique:users',
- 'password' => 'required|min:6|confirmed',
+ 'password' => 'required|min:5|confirmed',
]);
}
@@ -62,10 +63,14 @@ class RegisterController extends Controller
*/
protected function create(array $data)
{
- return User::create([
+ $user = User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => bcrypt($data['password']),
]);
+
+ $role = Role::where('name', 'admin')->first();
+ $user->attachRole($role);
+ return $user->refresh();
}
}
diff --git a/app/Http/Controllers/Frontend/BaseController.php b/app/Http/Controllers/Frontend/BaseController.php
index 8727055d..a1f09416 100644
--- a/app/Http/Controllers/Frontend/BaseController.php
+++ b/app/Http/Controllers/Frontend/BaseController.php
@@ -2,7 +2,9 @@
namespace App\Http\Controllers\Frontend;
-class BaseController extends Controller
+use App\Http\Controllers\AppBaseController;
+
+class BaseController extends AppBaseController
{
}
diff --git a/app/Http/Controllers/Frontend/DashboardController.php b/app/Http/Controllers/Frontend/DashboardController.php
index 71bf5ce0..c75827b9 100644
--- a/app/Http/Controllers/Frontend/DashboardController.php
+++ b/app/Http/Controllers/Frontend/DashboardController.php
@@ -11,6 +11,6 @@ class DashboardController extends BaseController
*/
public function index()
{
- return view('frontend/dashboard');
+ return view('frontend.dashboard');
}
}
diff --git a/app/Http/Requests/CreateAirportRequest.php b/app/Http/Requests/CreateAirportRequest.php
new file mode 100644
index 00000000..cfa70ca1
--- /dev/null
+++ b/app/Http/Requests/CreateAirportRequest.php
@@ -0,0 +1,30 @@
+ 'required'
+ ];
+
+ public function save(array $options = [])
+ {
+ if(in_array('icao', $options)) {
+ $options['icao'] = strtoupper($options['icao']);
+ }
+
+ return parent::save($options);
+ }
+}
diff --git a/app/Repositories/AirportRepository.php b/app/Repositories/AirportRepository.php
new file mode 100644
index 00000000..e94d4ba1
--- /dev/null
+++ b/app/Repositories/AirportRepository.php
@@ -0,0 +1,24 @@
+ 'laravel',
+ 'prefix' => 'phpvms',
];
diff --git a/database/migrations/2017_06_11_135707_create_airports_table.php b/database/migrations/2017_06_11_135707_create_airports_table.php
new file mode 100644
index 00000000..4d8993f8
--- /dev/null
+++ b/database/migrations/2017_06_11_135707_create_airports_table.php
@@ -0,0 +1,37 @@
+increments('id');
+ $table->string('icao', 5)->unique();
+ $table->string('name');
+ $table->string('location')->nullable();
+ $table->float('lat', 7, 4)->default(0.0);
+ $table->float('lon', 7, 4)->default(0.0);
+ $table->timestamps();
+ $table->softDeletes();
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ Schema::drop('airports');
+ }
+}
diff --git a/database/seeds/DatabaseSeeder.php b/database/seeds/DatabaseSeeder.php
index 5ec2951a..ee742a3d 100755
--- a/database/seeds/DatabaseSeeder.php
+++ b/database/seeds/DatabaseSeeder.php
@@ -1,5 +1,6 @@
call(AircraftClassesSeeder::class);
+ $this->user_seeder();
+ $this->airport_seeder();
+ }
+
+ protected function time() {
+ return Carbon::now()->format('Y-m-d H:i:s');
+ }
+ /**
+ * Add an initial admin user and roles
+ */
+ protected function user_seeder()
+ {
+ foreach ([
+ ['id' => 1,'name' => 'admin', 'display_name' => 'Administrators'],
+ ['id' => 2, 'name' => 'user', 'display_name' => 'Pilot'],
+ ] as $group) { DB::table('roles')->insert($group); }
+
+ DB::table('users')->insert([
+ 'id' => 1,
+ 'name' => 'Admin User',
+ 'email' => 'admin@phpvms.net',
+ 'password' => bcrypt('phpvms'),
+ 'created_at' => Carbon::now('UTC'),
+ 'updated_at' => Carbon::now('UTC'),
+ ]);
+
+ // add as both admin and user role
+ DB::table('role_user')->insert(['user_id' => 1, 'role_id' => 1]);
+ DB::table('role_user')->insert(['user_id' => 1, 'role_id' => 2]);
+ }
+
+ /**
+ * Add a few initial airports
+ */
+ protected function airport_seeder()
+ {
+ $airports = [
+ [
+ 'icao' => 'KAUS',
+ 'name' => 'Austin-Bergstrom International Airport',
+ 'location' => 'Austin, Texas, USA',
+ 'lat' => 30.1945278,
+ 'lon' => -97.6698889,
+ ],
+ [
+ 'icao' => 'KJFK',
+ 'name' => 'John F Kennedy International Airport',
+ 'location' => 'New York, New York, USA',
+ 'lat' => 40.6399257,
+ 'lon' => -73.7786950,
+ ],
+ ];
+
+ foreach($airports as $airport) {
+ DB::table('airports')->insert($airport);
+ }
}
}
diff --git a/database/seeds/InitialDataSeeder.php b/database/seeds/InitialDataSeeder.php
deleted file mode 100644
index c496523e..00000000
--- a/database/seeds/InitialDataSeeder.php
+++ /dev/null
@@ -1,39 +0,0 @@
-user_seeder();
- }
-
- /**
- * Add an initial admin user and roles
- */
- protected function user_seeder()
- {
- foreach ([
- ['id' => 1,'name' => 'admin', 'display_name' => 'Administrators'],
- ['id' => 2, 'name' => 'user', 'display_name' => 'Pilot'],
- ] as $group) { DB::table('roles')->insert($group); }
-
- DB::table('users')->insert([
- 'id' => 1,
- 'name' => 'Admin User',
- 'email' => 'admin@phpvms.net',
- 'password' => bcrypt('admin'),
- ]);
-
- DB::table('role_user')->insert([
- 'user_id' => 1,
- 'role_id' => 1,
- ]);
- }
-}
diff --git a/resources/views/admin/airports/create.blade.php b/resources/views/admin/airports/create.blade.php
new file mode 100644
index 00000000..ef4dec3f
--- /dev/null
+++ b/resources/views/admin/airports/create.blade.php
@@ -0,0 +1,22 @@
+@extends('admin.app')
+
+@section('content')
+ Add Airport
+
{!! $airport->icao !!}
+{!! $airport->name !!}
+{!! $airport->location !!}
+{!! $airport->lat !!}
+{!! $airport->lon !!}
+{!! $airport->created_at !!}
+{!! $airport->updated_at !!}
+| ICAO | +Name | +Location | +Action | + + + @foreach($airports as $airport) +
|---|---|---|---|
| {!! $airport->icao !!} | +{!! $airport->name !!} | +{!! $airport->location !!} ({!! $airport->lat !!}x{!! $airport->lon !!}) | ++ {!! Form::open(['route' => ['admin.airports.destroy', $airport->id], 'method' => 'delete']) !!} + + {!! Form::close() !!} + | +