some refactoring for tests and adding some tables
This commit is contained in:
5
Makefile
5
Makefile
@@ -19,6 +19,11 @@ db:
|
|||||||
sqlite3 database/testing.sqlite ""
|
sqlite3 database/testing.sqlite ""
|
||||||
php artisan migrate
|
php artisan migrate
|
||||||
|
|
||||||
|
unittest-db:
|
||||||
|
rm -f database/unittest.sqlite
|
||||||
|
sqlite3 database/unittest.sqlite ""
|
||||||
|
php artisan migrate:refresh --seed --env unittest
|
||||||
|
|
||||||
reset-db:
|
reset-db:
|
||||||
rm database/testing.sqlite
|
rm database/testing.sqlite
|
||||||
make db
|
make db
|
||||||
|
|||||||
155
app/Http/Controllers/Admin/AircraftClassController.php
Normal file
155
app/Http/Controllers/Admin/AircraftClassController.php
Normal file
@@ -0,0 +1,155 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use App\Http\Requests\CreateAircraftClassRequest;
|
||||||
|
use App\Http\Requests\UpdateAircraftClassRequest;
|
||||||
|
use App\Repositories\AircraftClassRepository;
|
||||||
|
use App\Http\Controllers\AppBaseController;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Flash;
|
||||||
|
use Prettus\Repository\Criteria\RequestCriteria;
|
||||||
|
use Response;
|
||||||
|
|
||||||
|
class AircraftClassController extends AppBaseController
|
||||||
|
{
|
||||||
|
/** @var AircraftClassRepository */
|
||||||
|
private $aircraftClassRepository;
|
||||||
|
|
||||||
|
public function __construct(AircraftClassRepository $aircraftClassRepo)
|
||||||
|
{
|
||||||
|
$this->aircraftClassRepository = $aircraftClassRepo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display a listing of the AircraftClass.
|
||||||
|
*
|
||||||
|
* @param Request $request
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
$this->aircraftClassRepository->pushCriteria(new RequestCriteria($request));
|
||||||
|
$aircraftClasses = $this->aircraftClassRepository->all();
|
||||||
|
|
||||||
|
return view('admin.aircraft_classes.index')
|
||||||
|
->with('aircraftClasses', $aircraftClasses);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new AircraftClass.
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
return view('admin.aircraft_classes.create');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created AircraftClass in storage.
|
||||||
|
*
|
||||||
|
* @param CreateAircraftClassRequest $request
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function store(CreateAircraftClassRequest $request)
|
||||||
|
{
|
||||||
|
$input = $request->all();
|
||||||
|
|
||||||
|
$aircraftClass = $this->aircraftClassRepository->create($input);
|
||||||
|
|
||||||
|
Flash::success('Aircraft Class saved successfully.');
|
||||||
|
|
||||||
|
return redirect(route('admin.aircraftClasses.index'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified AircraftClass.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
$aircraftClass = $this->aircraftClassRepository->findWithoutFail($id);
|
||||||
|
|
||||||
|
if (empty($aircraftClass)) {
|
||||||
|
Flash::error('Aircraft Class not found');
|
||||||
|
|
||||||
|
return redirect(route('admin.aircraftClasses.index'));
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('admin.aircraft_classes.show')->with('aircraftClass', $aircraftClass);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified AircraftClass.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
$aircraftClass = $this->aircraftClassRepository->findWithoutFail($id);
|
||||||
|
|
||||||
|
if (empty($aircraftClass)) {
|
||||||
|
Flash::error('Aircraft Class not found');
|
||||||
|
|
||||||
|
return redirect(route('admin.aircraftClasses.index'));
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('admin.aircraft_classes.edit')->with('aircraftClass', $aircraftClass);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified AircraftClass in storage.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @param UpdateAircraftClassRequest $request
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function update($id, UpdateAircraftClassRequest $request)
|
||||||
|
{
|
||||||
|
$aircraftClass = $this->aircraftClassRepository->findWithoutFail($id);
|
||||||
|
|
||||||
|
if (empty($aircraftClass)) {
|
||||||
|
Flash::error('Aircraft Class not found');
|
||||||
|
|
||||||
|
return redirect(route('admin.aircraftClasses.index'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$aircraftClass = $this->aircraftClassRepository->update($request->all(), $id);
|
||||||
|
|
||||||
|
Flash::success('Aircraft Class updated successfully.');
|
||||||
|
|
||||||
|
return redirect(route('admin.aircraftClasses.index'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified AircraftClass from storage.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
$aircraftClass = $this->aircraftClassRepository->findWithoutFail($id);
|
||||||
|
|
||||||
|
if (empty($aircraftClass)) {
|
||||||
|
Flash::error('Aircraft Class not found');
|
||||||
|
|
||||||
|
return redirect(route('admin.aircraftClasses.index'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->aircraftClassRepository->delete($id);
|
||||||
|
|
||||||
|
Flash::success('Aircraft Class deleted successfully.');
|
||||||
|
|
||||||
|
return redirect(route('admin.aircraftClasses.index'));
|
||||||
|
}
|
||||||
|
}
|
||||||
30
app/Http/Requests/CreateAircraftClassRequest.php
Normal file
30
app/Http/Requests/CreateAircraftClassRequest.php
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
use App\Models\AircraftClass;
|
||||||
|
|
||||||
|
class CreateAircraftClassRequest extends FormRequest
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function authorize()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
return AircraftClass::$rules;
|
||||||
|
}
|
||||||
|
}
|
||||||
30
app/Http/Requests/UpdateAircraftClassRequest.php
Normal file
30
app/Http/Requests/UpdateAircraftClassRequest.php
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
use App\Models\AircraftClass;
|
||||||
|
|
||||||
|
class UpdateAircraftClassRequest extends FormRequest
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function authorize()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
return AircraftClass::$rules;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,12 +15,10 @@ class Aircraft extends Model
|
|||||||
use SoftDeletes;
|
use SoftDeletes;
|
||||||
|
|
||||||
public $table = 'aircraft';
|
public $table = 'aircraft';
|
||||||
|
|
||||||
|
|
||||||
protected $dates = ['deleted_at'];
|
protected $dates = ['deleted_at'];
|
||||||
|
|
||||||
|
|
||||||
public $fillable = [
|
public $fillable = [
|
||||||
|
'aircraft_class_id',
|
||||||
'icao',
|
'icao',
|
||||||
'name',
|
'name',
|
||||||
'full_name',
|
'full_name',
|
||||||
@@ -51,5 +49,17 @@ class Aircraft extends Model
|
|||||||
'name' => 'required',
|
'name' => 'required',
|
||||||
'full_name' => 'required',
|
'full_name' => 'required',
|
||||||
'registration' => 'required',
|
'registration' => 'required',
|
||||||
|
'active' => 'default:1'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* foreign key
|
||||||
|
*/
|
||||||
|
public function class()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(
|
||||||
|
'App\Models\AircraftClass',
|
||||||
|
'aircraft_class_id'
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
47
app/Models/AircraftClass.php
Normal file
47
app/Models/AircraftClass.php
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Eloquent as Model;
|
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class AircraftClass
|
||||||
|
* @package App\Models
|
||||||
|
* @version June 9, 2017, 8:10 pm UTC
|
||||||
|
*/
|
||||||
|
class AircraftClass extends Model
|
||||||
|
{
|
||||||
|
//use SoftDeletes;
|
||||||
|
|
||||||
|
public $table = 'aircraft_classes';
|
||||||
|
|
||||||
|
protected $dates = ['deleted_at'];
|
||||||
|
|
||||||
|
public $fillable = [
|
||||||
|
'code',
|
||||||
|
'name',
|
||||||
|
'notes'
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that should be casted to native types.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $casts = [
|
||||||
|
'code' => 'string',
|
||||||
|
'name' => 'string',
|
||||||
|
'notes' => 'string'
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validation rules
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public static $rules = [
|
||||||
|
'code' => 'required',
|
||||||
|
'name' => 'required'
|
||||||
|
];
|
||||||
|
}
|
||||||
26
app/Repositories/AircraftClassRepository.php
Normal file
26
app/Repositories/AircraftClassRepository.php
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Repositories;
|
||||||
|
|
||||||
|
use App\Models\AircraftClass;
|
||||||
|
use InfyOm\Generator\Common\BaseRepository;
|
||||||
|
|
||||||
|
class AircraftClassRepository extends BaseRepository
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $fieldSearchable = [
|
||||||
|
'class',
|
||||||
|
'name',
|
||||||
|
'notes'
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configure the Model
|
||||||
|
**/
|
||||||
|
public function model()
|
||||||
|
{
|
||||||
|
return AircraftClass::class;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -21,7 +21,7 @@
|
|||||||
"mockery/mockery": "0.9.*",
|
"mockery/mockery": "0.9.*",
|
||||||
"phpunit/phpunit": "~5.0",
|
"phpunit/phpunit": "~5.0",
|
||||||
"symfony/css-selector": "3.1.*",
|
"symfony/css-selector": "3.1.*",
|
||||||
"symfony/dom-crawler": "3.1.*"
|
"symfony/dom-crawler": "3.1.*",
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"classmap": [
|
"classmap": [
|
||||||
|
|||||||
@@ -46,12 +46,6 @@ return [
|
|||||||
|
|
||||||
'connections' => [
|
'connections' => [
|
||||||
|
|
||||||
'testing' => [
|
|
||||||
'driver' => 'sqlite',
|
|
||||||
'database' => database_path('testing.sqlite'),
|
|
||||||
'prefix' => '',
|
|
||||||
],
|
|
||||||
|
|
||||||
'mysql' => [
|
'mysql' => [
|
||||||
'driver' => 'mysql',
|
'driver' => 'mysql',
|
||||||
'host' => env('DB_HOST', 'localhost'),
|
'host' => env('DB_HOST', 'localhost'),
|
||||||
@@ -66,6 +60,24 @@ return [
|
|||||||
'engine' => null,
|
'engine' => null,
|
||||||
],
|
],
|
||||||
|
|
||||||
|
'local' => [
|
||||||
|
'driver' => 'sqlite',
|
||||||
|
'database' => database_path('testing.sqlite'),
|
||||||
|
'prefix' => '',
|
||||||
|
],
|
||||||
|
|
||||||
|
'unittest' => [
|
||||||
|
'driver' => 'sqlite',
|
||||||
|
'database' => database_path('unittest.sqlite'),
|
||||||
|
'prefix' => '',
|
||||||
|
],
|
||||||
|
|
||||||
|
'testing' => [
|
||||||
|
'driver' => 'sqlite',
|
||||||
|
'database' => ':memory:',
|
||||||
|
'prefix' => '',
|
||||||
|
],
|
||||||
|
|
||||||
],
|
],
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
10
database/factories/AircraftClassFactory.php
Normal file
10
database/factories/AircraftClassFactory.php
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
$factory->define(App\Models\AircraftClass::class, function (Faker\Generator $faker) {
|
||||||
|
return [
|
||||||
|
'id' => 1,
|
||||||
|
'code' => 'H',
|
||||||
|
'name' => 'Heavy',
|
||||||
|
'notes' => 'Heavy aircraft',
|
||||||
|
];
|
||||||
|
});
|
||||||
@@ -1,16 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
| Model Factories
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
|
|
|
||||||
| Here you may define all of your model factories. Model factories give
|
|
||||||
| you a convenient way to create models for testing and seeding your
|
|
||||||
| database. Just tell the factory how a default model should look.
|
|
||||||
|
|
|
||||||
*/
|
|
||||||
|
|
||||||
$factory->define(App\User::class, function (Faker\Generator $faker) {
|
$factory->define(App\User::class, function (Faker\Generator $faker) {
|
||||||
static $password;
|
static $password;
|
||||||
|
|
||||||
|
|||||||
@@ -9,18 +9,37 @@ class CreateAircraftsTable extends Migration
|
|||||||
{
|
{
|
||||||
Schema::create('aircraft', function (Blueprint $table) {
|
Schema::create('aircraft', function (Blueprint $table) {
|
||||||
$table->increments('id');
|
$table->increments('id');
|
||||||
|
$table->integer('aircraft_class_id')->unsigned();
|
||||||
$table->string('icao');
|
$table->string('icao');
|
||||||
$table->string('name');
|
$table->string('name');
|
||||||
$table->string('full_name')->nullable();
|
$table->string('full_name')->nullable();
|
||||||
$table->string('registration')->nullable();
|
$table->string('registration')->nullable();
|
||||||
$table->boolean('active');
|
$table->string('tail_number')->nullable();
|
||||||
|
$table->string('cargo_capacity')->nullable();
|
||||||
|
$table->string('fuel_capacity')->nullable();
|
||||||
|
$table->boolean('active')->default(true);
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
$table->softDeletes();
|
$table->softDeletes();
|
||||||
|
|
||||||
|
$table->index('icao');
|
||||||
|
$table->unique('registration');
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::create('aircraft_classes', function (Blueprint $table) {
|
||||||
|
$table->increments('id');
|
||||||
|
$table->string('code');
|
||||||
|
$table->string('name');
|
||||||
|
$table->string('notes')->nullable();
|
||||||
|
$table->timestamps();
|
||||||
|
$table->softDeletes();
|
||||||
|
|
||||||
|
$table->index('code');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public function down()
|
public function down()
|
||||||
{
|
{
|
||||||
Schema::drop('aircraft');
|
Schema::drop('aircraft');
|
||||||
|
Schema::drop('aircraft_classes');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,56 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"name": "id",
|
|
||||||
"dbType": "increments",
|
|
||||||
"htmlType": "",
|
|
||||||
"validations": "",
|
|
||||||
"searchable": false,
|
|
||||||
"fillable": false,
|
|
||||||
"primary": true,
|
|
||||||
"inForm": false,
|
|
||||||
"inIndex": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "icao",
|
|
||||||
"dbType": "string",
|
|
||||||
"htmlType": "text",
|
|
||||||
"validations": "required|max:4",
|
|
||||||
"searchable": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "name",
|
|
||||||
"dbType": "string",
|
|
||||||
"htmlType": "text",
|
|
||||||
"validations": "required",
|
|
||||||
"searchable": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "enabled",
|
|
||||||
"dbType": "boolean",
|
|
||||||
"htmlType": "checkbox",
|
|
||||||
"validations": "",
|
|
||||||
"searchable": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "created_at",
|
|
||||||
"dbType": "timestamp",
|
|
||||||
"htmlType": "",
|
|
||||||
"validations": "",
|
|
||||||
"searchable": false,
|
|
||||||
"fillable": false,
|
|
||||||
"primary": false,
|
|
||||||
"inForm": false,
|
|
||||||
"inIndex": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "updated_at",
|
|
||||||
"dbType": "timestamp",
|
|
||||||
"htmlType": "",
|
|
||||||
"validations": "",
|
|
||||||
"searchable": false,
|
|
||||||
"fillable": false,
|
|
||||||
"primary": false,
|
|
||||||
"inForm": false,
|
|
||||||
"inIndex": false
|
|
||||||
}
|
|
||||||
]
|
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"name": "id",
|
|
||||||
"dbType": "increments",
|
|
||||||
"htmlType": "",
|
|
||||||
"validations": "",
|
|
||||||
"searchable": false,
|
|
||||||
"fillable": false,
|
|
||||||
"primary": true,
|
|
||||||
"inForm": false,
|
|
||||||
"inIndex": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "code",
|
|
||||||
"dbType": "string",
|
|
||||||
"htmlType": "text",
|
|
||||||
"validations": "required",
|
|
||||||
"searchable": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "name",
|
|
||||||
"dbType": "string",
|
|
||||||
"htmlType": "text",
|
|
||||||
"validations": "required",
|
|
||||||
"searchable": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "enabled",
|
|
||||||
"dbType": "boolean",
|
|
||||||
"htmlType": "checkbox",
|
|
||||||
"validations": "",
|
|
||||||
"searchable": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "created_at",
|
|
||||||
"dbType": "timestamp",
|
|
||||||
"htmlType": "",
|
|
||||||
"validations": "",
|
|
||||||
"searchable": false,
|
|
||||||
"fillable": false,
|
|
||||||
"primary": false,
|
|
||||||
"inForm": false,
|
|
||||||
"inIndex": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "updated_at",
|
|
||||||
"dbType": "timestamp",
|
|
||||||
"htmlType": "",
|
|
||||||
"validations": "",
|
|
||||||
"searchable": false,
|
|
||||||
"fillable": false,
|
|
||||||
"primary": false,
|
|
||||||
"inForm": false,
|
|
||||||
"inIndex": false
|
|
||||||
}
|
|
||||||
]
|
|
||||||
18
database/seeds/AircraftClassesSeeder.php
Normal file
18
database/seeds/AircraftClassesSeeder.php
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Seeds;
|
||||||
|
|
||||||
|
use Illuminate\Database\Seeder;
|
||||||
|
|
||||||
|
class AircraftClassesSeeder extends Seeder
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the database seeds.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function run()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,6 +11,6 @@ class DatabaseSeeder extends Seeder
|
|||||||
*/
|
*/
|
||||||
public function run()
|
public function run()
|
||||||
{
|
{
|
||||||
// $this->call(UsersTableSeeder::class);
|
// $this->call(AircraftClassesSeeder::class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
<env name="APP_ENV" value="testing"/>
|
<env name="APP_ENV" value="testing"/>
|
||||||
<env name="APP_KEY" value="base64:ve66Z5Kt/zTN3p++0zOPu854PHfZkwJE5VuoFAlzHtI="/>
|
<env name="APP_KEY" value="base64:ve66Z5Kt/zTN3p++0zOPu854PHfZkwJE5VuoFAlzHtI="/>
|
||||||
<env name="APP_DEBUG" value="true"/>
|
<env name="APP_DEBUG" value="true"/>
|
||||||
|
<env name="DB_CONNECTION" value="unittest"/>
|
||||||
<env name="CACHE_DRIVER" value="array"/>
|
<env name="CACHE_DRIVER" value="array"/>
|
||||||
<env name="SESSION_DRIVER" value="array"/>
|
<env name="SESSION_DRIVER" value="array"/>
|
||||||
<env name="QUEUE_DRIVER" value="sync"/>
|
<env name="QUEUE_DRIVER" value="sync"/>
|
||||||
|
|||||||
BIN
public/img/bg.jpg
Normal file
BIN
public/img/bg.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 320 KiB |
BIN
public/img/bg2.jpg
Normal file
BIN
public/img/bg2.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.0 MiB |
24
resources/views/admin/aircraft_classes/create.blade.php
Normal file
24
resources/views/admin/aircraft_classes/create.blade.php
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
@extends('admin.app')
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
<section class="content-header">
|
||||||
|
<h1>
|
||||||
|
Aircraft Classes
|
||||||
|
</h1>
|
||||||
|
</section>
|
||||||
|
<div class="content">
|
||||||
|
@include('adminlte-templates::common.errors')
|
||||||
|
<div class="box box-primary">
|
||||||
|
|
||||||
|
<div class="box-body">
|
||||||
|
<div class="row">
|
||||||
|
{!! Form::open(['route' => 'admin.aircraftClasses.store']) !!}
|
||||||
|
|
||||||
|
@include('admin.aircraft_classes.fields')
|
||||||
|
|
||||||
|
{!! Form::close() !!}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endsection
|
||||||
23
resources/views/admin/aircraft_classes/edit.blade.php
Normal file
23
resources/views/admin/aircraft_classes/edit.blade.php
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
@extends('layouts.app')
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
<section class="content-header">
|
||||||
|
<h1>
|
||||||
|
Aircraft Class
|
||||||
|
</h1>
|
||||||
|
</section>
|
||||||
|
<div class="content">
|
||||||
|
@include('adminlte-templates::common.errors')
|
||||||
|
<div class="box box-primary">
|
||||||
|
<div class="box-body">
|
||||||
|
<div class="row">
|
||||||
|
{!! Form::model($aircraftClass, ['route' => ['admin.aircraftClasses.update', $aircraftClass->id], 'method' => 'patch']) !!}
|
||||||
|
|
||||||
|
@include('admin.aircraft_classes.fields')
|
||||||
|
|
||||||
|
{!! Form::close() !!}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endsection
|
||||||
7
resources/views/admin/aircraft_classes/fields.blade.php
Normal file
7
resources/views/admin/aircraft_classes/fields.blade.php
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
<!-- Submit Field -->
|
||||||
|
<div class="form-group col-sm-12">
|
||||||
|
{!! Form::submit('Save', ['class' => 'btn btn-primary']) !!}
|
||||||
|
<a href="{!! route('admin.aircraftClasses.index') !!}" class="btn btn-default">Cancel</a>
|
||||||
|
</div>
|
||||||
23
resources/views/admin/aircraft_classes/index.blade.php
Normal file
23
resources/views/admin/aircraft_classes/index.blade.php
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
@extends('layouts.app')
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
<section class="content-header">
|
||||||
|
<h1 class="pull-left">Aircraft Classes</h1>
|
||||||
|
<h1 class="pull-right">
|
||||||
|
<a class="btn btn-primary pull-right" style="margin-top: -10px;margin-bottom: 5px" href="{!! route('admin.aircraftClasses.create') !!}">Add New</a>
|
||||||
|
</h1>
|
||||||
|
</section>
|
||||||
|
<div class="content">
|
||||||
|
<div class="clearfix"></div>
|
||||||
|
|
||||||
|
@include('flash::message')
|
||||||
|
|
||||||
|
<div class="clearfix"></div>
|
||||||
|
<div class="box box-primary">
|
||||||
|
<div class="box-body">
|
||||||
|
@include('admin.aircraft_classes.table')
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endsection
|
||||||
|
|
||||||
19
resources/views/admin/aircraft_classes/show.blade.php
Normal file
19
resources/views/admin/aircraft_classes/show.blade.php
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
@extends('layouts.app')
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
<section class="content-header">
|
||||||
|
<h1>
|
||||||
|
Aircraft Class
|
||||||
|
</h1>
|
||||||
|
</section>
|
||||||
|
<div class="content">
|
||||||
|
<div class="box box-primary">
|
||||||
|
<div class="box-body">
|
||||||
|
<div class="row" style="padding-left: 20px">
|
||||||
|
@include('admin.aircraft_classes.show_fields')
|
||||||
|
<a href="{!! route('admin.aircraftClasses.index') !!}" class="btn btn-default">Back</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endsection
|
||||||
36
resources/views/admin/aircraft_classes/show_fields.blade.php
Normal file
36
resources/views/admin/aircraft_classes/show_fields.blade.php
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
<!-- Id Field -->
|
||||||
|
<div class="form-group">
|
||||||
|
{!! Form::label('id', 'Id:') !!}
|
||||||
|
<p>{!! $aircraftClass->id !!}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Class Field -->
|
||||||
|
<div class="form-group">
|
||||||
|
{!! Form::label('class', 'Class:') !!}
|
||||||
|
<p>{!! $aircraftClass->class !!}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Name Field -->
|
||||||
|
<div class="form-group">
|
||||||
|
{!! Form::label('name', 'Name:') !!}
|
||||||
|
<p>{!! $aircraftClass->name !!}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Notes Field -->
|
||||||
|
<div class="form-group">
|
||||||
|
{!! Form::label('notes', 'Notes:') !!}
|
||||||
|
<p>{!! $aircraftClass->notes !!}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Created At Field -->
|
||||||
|
<div class="form-group">
|
||||||
|
{!! Form::label('created_at', 'Created At:') !!}
|
||||||
|
<p>{!! $aircraftClass->created_at !!}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Updated At Field -->
|
||||||
|
<div class="form-group">
|
||||||
|
{!! Form::label('updated_at', 'Updated At:') !!}
|
||||||
|
<p>{!! $aircraftClass->updated_at !!}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
26
resources/views/admin/aircraft_classes/table.blade.php
Normal file
26
resources/views/admin/aircraft_classes/table.blade.php
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<table class="table table-responsive" id="aircraftClasses-table">
|
||||||
|
<thead>
|
||||||
|
<th>Class</th>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Notes</th>
|
||||||
|
<th colspan="3">Action</th>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@foreach($aircraftClasses as $aircraftClass)
|
||||||
|
<tr>
|
||||||
|
<td>{!! $aircraftClass->class !!}</td>
|
||||||
|
<td>{!! $aircraftClass->name !!}</td>
|
||||||
|
<td>{!! $aircraftClass->notes !!}</td>
|
||||||
|
<td>
|
||||||
|
{!! Form::open(['route' => ['admin.aircraftClasses.destroy', $aircraftClass->id], 'method' => 'delete']) !!}
|
||||||
|
<div class='btn-group'>
|
||||||
|
<a href="{!! route('admin.aircraftClasses.show', [$aircraftClass->id]) !!}" class='btn btn-default btn-xs'><i class="glyphicon glyphicon-eye-open"></i></a>
|
||||||
|
<a href="{!! route('admin.aircraftClasses.edit', [$aircraftClass->id]) !!}" class='btn btn-default btn-xs'><i class="glyphicon glyphicon-edit"></i></a>
|
||||||
|
{!! Form::button('<i class="glyphicon glyphicon-trash"></i>', ['type' => 'submit', 'class' => 'btn btn-danger btn-xs', 'onclick' => "return confirm('Are you sure?')"]) !!}
|
||||||
|
</div>
|
||||||
|
{!! Form::close() !!}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
@endforeach
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
|
||||||
<title>Laravel</title>
|
<title>phpvms4</title>
|
||||||
|
|
||||||
<!-- Fonts -->
|
<!-- Fonts -->
|
||||||
<link href="https://fonts.googleapis.com/css?family=Raleway:100,600" rel="stylesheet" type="text/css">
|
<link href="https://fonts.googleapis.com/css?family=Raleway:100,600" rel="stylesheet" type="text/css">
|
||||||
@@ -19,6 +19,11 @@
|
|||||||
font-weight: 100;
|
font-weight: 100;
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
background: url(img/bg2.jpg) no-repeat center center fixed;
|
||||||
|
-webkit-background-size: cover;
|
||||||
|
-moz-background-size: cover;
|
||||||
|
-o-background-size: cover;
|
||||||
|
background-size: cover;
|
||||||
}
|
}
|
||||||
|
|
||||||
.full-height {
|
.full-height {
|
||||||
|
|||||||
87
resources/views/layouts/app.blade.php
Normal file
87
resources/views/layouts/app.blade.php
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
|
||||||
|
<!-- CSRF Token -->
|
||||||
|
<meta name="csrf-token" content="{{ csrf_token() }}">
|
||||||
|
|
||||||
|
<title>{{ config('app.name', 'Laravel') }}</title>
|
||||||
|
|
||||||
|
<!-- Styles -->
|
||||||
|
<link href="/css/app.css" rel="stylesheet">
|
||||||
|
|
||||||
|
<!-- Scripts -->
|
||||||
|
<script>
|
||||||
|
window.Laravel = <?php echo json_encode([
|
||||||
|
'csrfToken' => csrf_token(),
|
||||||
|
]); ?>
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="app">
|
||||||
|
<nav class="navbar navbar-default navbar-static-top">
|
||||||
|
<div class="container">
|
||||||
|
<div class="navbar-header">
|
||||||
|
|
||||||
|
<!-- Collapsed Hamburger -->
|
||||||
|
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#app-navbar-collapse">
|
||||||
|
<span class="sr-only">Toggle Navigation</span>
|
||||||
|
<span class="icon-bar"></span>
|
||||||
|
<span class="icon-bar"></span>
|
||||||
|
<span class="icon-bar"></span>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<!-- Branding Image -->
|
||||||
|
<a class="navbar-brand" href="{{ url('/') }}">
|
||||||
|
{{ config('app.name', 'Laravel') }}
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="collapse navbar-collapse" id="app-navbar-collapse">
|
||||||
|
<!-- Left Side Of Navbar -->
|
||||||
|
<ul class="nav navbar-nav">
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<!-- Right Side Of Navbar -->
|
||||||
|
<ul class="nav navbar-nav navbar-right">
|
||||||
|
<!-- Authentication Links -->
|
||||||
|
@if (Auth::guest())
|
||||||
|
<li><a href="{{ url('/login') }}">Login</a></li>
|
||||||
|
<li><a href="{{ url('/register') }}">Register</a></li>
|
||||||
|
@else
|
||||||
|
<li class="dropdown">
|
||||||
|
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
|
||||||
|
{{ Auth::user()->name }} <span class="caret"></span>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<ul class="dropdown-menu" role="menu">
|
||||||
|
<li>
|
||||||
|
<a href="{{ url('/logout') }}"
|
||||||
|
onclick="event.preventDefault();
|
||||||
|
document.getElementById('logout-form').submit();">
|
||||||
|
Logout
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<form id="logout-form" action="{{ url('/logout') }}" method="POST" style="display: none;">
|
||||||
|
{{ csrf_field() }}
|
||||||
|
</form>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
@endif
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
@yield('content')
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Scripts -->
|
||||||
|
<script src="/js/app.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -14,4 +14,5 @@ Route::group([
|
|||||||
], function () {
|
], function () {
|
||||||
Route::resource('airlines', 'AirlinesController');
|
Route::resource('airlines', 'AirlinesController');
|
||||||
Route::resource('aircraft', 'AircraftController');
|
Route::resource('aircraft', 'AircraftController');
|
||||||
|
Route::resource('aircraftclasses', 'AircraftClassController');
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -24,3 +24,13 @@ Route::group([
|
|||||||
Route::resource('dashboard', 'DashboardController');
|
Route::resource('dashboard', 'DashboardController');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Route::get('admin/aircraftClasses', ['as'=> 'admin.aircraftClasses.index', 'uses' => 'AircraftClassController@index']);
|
||||||
|
Route::post('admin/aircraftClasses', ['as'=> 'admin.aircraftClasses.store', 'uses' => 'AircraftClassController@store']);
|
||||||
|
Route::get('admin/aircraftClasses/create', ['as'=> 'admin.aircraftClasses.create', 'uses' => 'AircraftClassController@create']);
|
||||||
|
Route::put('admin/aircraftClasses/{aircraftClasses}', ['as'=> 'admin.aircraftClasses.update', 'uses' => 'AircraftClassController@update']);
|
||||||
|
Route::patch('admin/aircraftClasses/{aircraftClasses}', ['as'=> 'admin.aircraftClasses.update', 'uses' => 'AircraftClassController@update']);
|
||||||
|
Route::delete('admin/aircraftClasses/{aircraftClasses}', ['as'=> 'admin.aircraftClasses.destroy', 'uses' => 'AircraftClassController@destroy']);
|
||||||
|
Route::get('admin/aircraftClasses/{aircraftClasses}', ['as'=> 'admin.aircraftClasses.show', 'uses' => 'AircraftClassController@show']);
|
||||||
|
Route::get('admin/aircraftClasses/{aircraftClasses}/edit', ['as'=> 'admin.aircraftClasses.edit', 'uses' => 'AircraftClassController@edit']);
|
||||||
|
|||||||
@@ -1,26 +1,33 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use App\Models\Aircraft;
|
||||||
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
||||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
|
||||||
|
|
||||||
|
|
||||||
class AircraftTest extends TestCase
|
class AircraftTest extends TestCase
|
||||||
{
|
{
|
||||||
|
protected $aircraft,
|
||||||
protected $repo;
|
$aircraft_class;
|
||||||
|
|
||||||
public function setUp() {
|
public function setUp() {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
$this->repo = $this->createRepository('AircraftRepository');
|
$this->aircraft = $this->createRepository('AircraftRepository');
|
||||||
|
$this->aircraft_class = $this->createRepository('AircraftClassRepository');
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* A basic test example.
|
public function testAircraftClasses()
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function testRepository()
|
|
||||||
{
|
{
|
||||||
print_r($this->repo->model());
|
factory(App\Models\AircraftClass::class)->create();
|
||||||
|
|
||||||
|
$this->aircraft->create([
|
||||||
|
'aircraft_class_id' => 1,
|
||||||
|
'icao' => 'B744',
|
||||||
|
'name' => 'Boeing 747',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$aircraft = App\Models\Aircraft::where('icao', 'B744')->first();
|
||||||
|
$this->assertEquals('B744', $aircraft->icao, 'ICAO matching');
|
||||||
|
$this->assertEquals('H', $aircraft->class->code, 'Check belongsTo relationship');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,11 +9,25 @@ abstract class TestCase extends Illuminate\Foundation\Testing\TestCase
|
|||||||
*/
|
*/
|
||||||
protected $app;
|
protected $app;
|
||||||
protected $baseUrl = 'http://localhost';
|
protected $baseUrl = 'http://localhost';
|
||||||
|
protected $connectionsToTransact = ['testing'];
|
||||||
|
|
||||||
public function __construct($name = null, array $data = [], $dataName = '') {
|
public function __construct($name = null, array $data = [], $dataName = '') {
|
||||||
parent::__construct($name, $data, $dataName);
|
parent::__construct($name, $data, $dataName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function reset_db(){
|
||||||
|
exec('make -f ' . __DIR__ . '/../Makefile unittest-db');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setUp() {
|
||||||
|
parent::setUp();
|
||||||
|
$this->reset_db();
|
||||||
|
/*
|
||||||
|
Artisan::call('migrate');
|
||||||
|
Artisan::call('db:seed');
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the application.
|
* Creates the application.
|
||||||
*
|
*
|
||||||
@@ -23,11 +37,12 @@ abstract class TestCase extends Illuminate\Foundation\Testing\TestCase
|
|||||||
{
|
{
|
||||||
$app = require __DIR__.'/../bootstrap/app.php';
|
$app = require __DIR__.'/../bootstrap/app.php';
|
||||||
$app->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();
|
$app->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();
|
||||||
|
//$app['config']->set('database.default','testing');
|
||||||
return $app;
|
return $app;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createRepository($repo_name) {
|
public function createRepository($repo_name) {
|
||||||
$app = $this->createApplication();
|
$app = $this->createApplication();
|
||||||
return $app->make('App\Repositories\\' + $repo_name);
|
return $app->make('App\Repositories\\' . $repo_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user