* Add public/private pages #641 * Cleanup the form requests
This commit is contained in:
10
app/Contracts/Composer.php
Normal file
10
app/Contracts/Composer.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Contracts;
|
||||
|
||||
use Illuminate\View\View;
|
||||
|
||||
abstract class Composer
|
||||
{
|
||||
abstract public function compose(View $view);
|
||||
}
|
||||
@@ -2,15 +2,14 @@
|
||||
|
||||
namespace App\Contracts;
|
||||
|
||||
/**
|
||||
* Class FormRequest
|
||||
*/
|
||||
class FormRequest extends \Illuminate\Foundation\Http\FormRequest
|
||||
{
|
||||
/**
|
||||
* Authorized by default
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -18,7 +17,7 @@ class FormRequest extends \Illuminate\Foundation\Http\FormRequest
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
public function rules(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
44
app/Database/migrations/2020_03_27_174238_create_pages.php
Normal file
44
app/Database/migrations/2020_03_27_174238_create_pages.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* Create the pages
|
||||
* https://github.com/nabeelio/phpvms/issues/641
|
||||
*/
|
||||
class CreatePages extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('pages', function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->string('name');
|
||||
$table->string('slug');
|
||||
$table->string('icon');
|
||||
$table->unsignedSmallInteger('type');
|
||||
$table->boolean('public');
|
||||
$table->boolean('enabled');
|
||||
$table->mediumText('body');
|
||||
$table->timestamps();
|
||||
|
||||
$table->index('slug');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('pages');
|
||||
}
|
||||
}
|
||||
@@ -30,6 +30,9 @@
|
||||
- name: finances
|
||||
display_name: Finances
|
||||
description: Create/view finance related items
|
||||
- name: pages
|
||||
display_name: Pages
|
||||
description: Add/edit/delete pages
|
||||
- name: pireps
|
||||
display_name: PIREPs
|
||||
description: Accept/reject/edit PIREPs
|
||||
|
||||
43
app/Exceptions/PageNotFound.php
Normal file
43
app/Exceptions/PageNotFound.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Exception;
|
||||
|
||||
class PageNotFound extends AbstractHttpException
|
||||
{
|
||||
private $exception;
|
||||
|
||||
public function __construct(Exception $exception)
|
||||
{
|
||||
$this->exception = $exception;
|
||||
parent::__construct(
|
||||
404,
|
||||
$exception->getMessage()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the RFC 7807 error type (without the URL root)
|
||||
*/
|
||||
public function getErrorType(): string
|
||||
{
|
||||
return 'not-found';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the detailed error string
|
||||
*/
|
||||
public function getErrorDetails(): string
|
||||
{
|
||||
return $this->getMessage();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an array with the error details, merged with the RFC7807 response
|
||||
*/
|
||||
public function getErrorMetadata(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
38
app/Http/Composers/PageLinksComposer.php
Normal file
38
app/Http/Composers/PageLinksComposer.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Composers;
|
||||
|
||||
use App\Contracts\Composer;
|
||||
use App\Repositories\PageRepository;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class PageLinksComposer extends Composer
|
||||
{
|
||||
protected $pageRepo;
|
||||
|
||||
/**
|
||||
* PageLinksComposer constructor.
|
||||
*
|
||||
* @param \App\Repositories\PageRepository $pageRepo
|
||||
*/
|
||||
public function __construct(PageRepository $pageRepo)
|
||||
{
|
||||
$this->pageRepo = $pageRepo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Illuminate\View\View $view
|
||||
*/
|
||||
public function compose(View $view)
|
||||
{
|
||||
// If not logged in, then only get the public pages
|
||||
$w = ['enabled' => true];
|
||||
if (!Auth::check()) {
|
||||
$w = ['public' => true];
|
||||
}
|
||||
|
||||
$pages = $this->pageRepo->findWhere($w, ['id', 'name', 'slug', 'icon']);
|
||||
$view->with('page_links', $pages);
|
||||
}
|
||||
}
|
||||
@@ -2,10 +2,11 @@
|
||||
|
||||
namespace App\Http\Composers;
|
||||
|
||||
use App\Contracts\Composer;
|
||||
use App\Services\VersionService;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class VersionComposer
|
||||
class VersionComposer extends Composer
|
||||
{
|
||||
protected $versionSvc;
|
||||
|
||||
|
||||
152
app/Http/Controllers/Admin/PagesController.php
Normal file
152
app/Http/Controllers/Admin/PagesController.php
Normal file
@@ -0,0 +1,152 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Contracts\Controller;
|
||||
use App\Http\Requests\CreatePageRequest;
|
||||
use App\Http\Requests\UpdatePageRequest;
|
||||
use App\Repositories\PageRepository;
|
||||
use Illuminate\Http\Request;
|
||||
use Laracasts\Flash\Flash;
|
||||
|
||||
class PagesController extends Controller
|
||||
{
|
||||
private $pageRepo;
|
||||
|
||||
/**
|
||||
* @param PageRepository $pageRepo
|
||||
*/
|
||||
public function __construct(PageRepository $pageRepo)
|
||||
{
|
||||
$this->pageRepo = $pageRepo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$pages = $this->pageRepo->all();
|
||||
|
||||
return view('admin.pages.index', [
|
||||
'pages' => $pages,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new Airlines.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return view('admin.pages.create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created Airlines in storage.
|
||||
*
|
||||
* @param \App\Http\Requests\CreatePageRequest $request
|
||||
*
|
||||
* @throws \Prettus\Validator\Exceptions\ValidatorException
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||
*/
|
||||
public function store(CreatePageRequest $request)
|
||||
{
|
||||
$input = $request->all();
|
||||
$this->pageRepo->create($input);
|
||||
|
||||
Flash::success('Page saved successfully.');
|
||||
return redirect(route('admin.pages.index'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified page
|
||||
*
|
||||
* @param int $id
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
$pages = $this->pageRepo->findWithoutFail($id);
|
||||
|
||||
if (empty($pages)) {
|
||||
Flash::error('Page not found');
|
||||
return redirect(route('admin.page.index'));
|
||||
}
|
||||
|
||||
return view('admin.pages.show', [
|
||||
'pages' => $pages,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified pages
|
||||
*
|
||||
* @param int $id
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$page = $this->pageRepo->findWithoutFail($id);
|
||||
|
||||
if (empty($page)) {
|
||||
Flash::error('Page not found');
|
||||
return redirect(route('admin.pages.index'));
|
||||
}
|
||||
|
||||
return view('admin.pages.edit', [
|
||||
'page' => $page,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified Airlines in storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @param UpdatePageRequest $request
|
||||
*
|
||||
* @throws \Prettus\Validator\Exceptions\ValidatorException
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function update($id, UpdatePageRequest $request)
|
||||
{
|
||||
$page = $this->pageRepo->findWithoutFail($id);
|
||||
|
||||
if (empty($page)) {
|
||||
Flash::error('page not found');
|
||||
return redirect(route('admin.pages.index'));
|
||||
}
|
||||
|
||||
$this->pageRepo->update($request->all(), $id);
|
||||
|
||||
Flash::success('pages updated successfully.');
|
||||
return redirect(route('admin.pages.index'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified Airlines from storage.
|
||||
*
|
||||
* @param int $id
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
$pages = $this->pageRepo->findWithoutFail($id);
|
||||
|
||||
if (empty($pages)) {
|
||||
Flash::error('Page not found');
|
||||
return redirect(route('admin.pages.index'));
|
||||
}
|
||||
|
||||
$this->pageRepo->delete($id);
|
||||
|
||||
Flash::success('page deleted successfully.');
|
||||
return redirect(route('admin.pages.index'));
|
||||
}
|
||||
}
|
||||
@@ -5,11 +5,8 @@ namespace App\Http\Controllers\Frontend;
|
||||
use App\Contracts\Controller;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Log;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Class HomeController
|
||||
*/
|
||||
class HomeController extends Controller
|
||||
{
|
||||
/**
|
||||
|
||||
38
app/Http/Controllers/Frontend/PageController.php
Normal file
38
app/Http/Controllers/Frontend/PageController.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Frontend;
|
||||
|
||||
use App\Contracts\Controller;
|
||||
use App\Exceptions\PageNotFound;
|
||||
use App\Repositories\PageRepository;
|
||||
use Exception;
|
||||
|
||||
class PageController extends Controller
|
||||
{
|
||||
private $pageRepo;
|
||||
|
||||
/**
|
||||
* @param \App\Repositories\PageRepository $pageRepo
|
||||
*/
|
||||
public function __construct(PageRepository $pageRepo)
|
||||
{
|
||||
$this->pageRepo = $pageRepo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the page
|
||||
*
|
||||
* @param $slug
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function show($slug)
|
||||
{
|
||||
$page = $this->pageRepo->findWhere(['slug' => $slug])->first();
|
||||
if (!$page) {
|
||||
throw new PageNotFound(new Exception('Page not found'));
|
||||
}
|
||||
|
||||
return view('pages.index', ['page' => $page]);
|
||||
}
|
||||
}
|
||||
@@ -8,11 +8,9 @@ class CommentRequest extends FormRequest
|
||||
{
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
return [
|
||||
'comment' => 'required',
|
||||
'created_at' => 'sometimes|date',
|
||||
];
|
||||
|
||||
return $rules;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,9 +4,6 @@ namespace App\Http\Requests\Acars;
|
||||
|
||||
use App\Contracts\FormRequest;
|
||||
|
||||
/**
|
||||
* Class PrefileRequest
|
||||
*/
|
||||
class FieldsRequest extends FormRequest
|
||||
{
|
||||
public function rules(): array
|
||||
|
||||
@@ -16,7 +16,7 @@ class FileRequest extends FormRequest
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
return [
|
||||
'distance' => 'required|numeric',
|
||||
'flight_time' => 'required|integer',
|
||||
'fuel_used' => 'required|numeric',
|
||||
@@ -48,7 +48,5 @@ class FileRequest extends FormRequest
|
||||
'fares.*.id' => 'required',
|
||||
'fares.*.count' => 'required|numeric',
|
||||
];
|
||||
|
||||
return $rules;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,14 +16,12 @@ class LogRequest extends FormRequest
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
return [
|
||||
'logs' => 'required|array',
|
||||
'logs.*.log' => 'required',
|
||||
'logs.*.lat' => 'sometimes|numeric',
|
||||
'logs.*.lon' => 'sometimes|numeric',
|
||||
'logs.*.created_at' => 'sometimes|date',
|
||||
];
|
||||
|
||||
return $rules;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ class PositionRequest extends FormRequest
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
return [
|
||||
'positions' => 'required|array',
|
||||
'positions.*.lat' => 'required|numeric',
|
||||
'positions.*.lon' => 'required|numeric',
|
||||
@@ -36,7 +36,5 @@ class PositionRequest extends FormRequest
|
||||
'positions.*.sim_time' => 'sometimes|date',
|
||||
'positions.*.created_at' => 'sometimes|date',
|
||||
];
|
||||
|
||||
return $rules;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ class RouteRequest extends FormRequest
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
return [
|
||||
'route' => 'required|array',
|
||||
'route.*.name' => 'required',
|
||||
'route.*.order' => 'required|int',
|
||||
@@ -24,7 +24,5 @@ class RouteRequest extends FormRequest
|
||||
'route.*.lat' => 'required|numeric',
|
||||
'route.*.lon' => 'required|numeric',
|
||||
];
|
||||
|
||||
return $rules;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ class UpdateRequest extends FormRequest
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
return [
|
||||
'airline_id' => 'nullable|exists:airlines,id',
|
||||
'aircraft_id' => 'nullable|exists:aircraft,id',
|
||||
'flight_id' => 'sometimes|nullable|exists:flights,id',
|
||||
@@ -50,7 +50,5 @@ class UpdateRequest extends FormRequest
|
||||
'fares.*.id' => 'required',
|
||||
'fares.*.count' => 'required|numeric',
|
||||
];
|
||||
|
||||
return $rules;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use App\Contracts\FormRequest;
|
||||
use App\Models\Aircraft;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class CreateAircraftRequest extends FormRequest
|
||||
{
|
||||
|
||||
@@ -2,17 +2,12 @@
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use App\Contracts\FormRequest;
|
||||
use App\Models\Airline;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class CreateAirlineRequest extends FormRequest
|
||||
{
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules()
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = Airline::$rules;
|
||||
$rules['iata'] .= '|unique:airlines';
|
||||
|
||||
@@ -2,24 +2,11 @@
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use App\Contracts\FormRequest;
|
||||
use App\Models\Airport;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
/**
|
||||
* Class CreateAirportRequest
|
||||
*/
|
||||
class CreateAirportRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
|
||||
@@ -2,27 +2,17 @@
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use App\Contracts\FormRequest;
|
||||
use App\Models\Award;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class CreateAwardRequest 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()
|
||||
public function rules(): array
|
||||
{
|
||||
return Award::$rules;
|
||||
}
|
||||
|
||||
@@ -2,21 +2,11 @@
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use App\Contracts\FormRequest;
|
||||
use App\Models\Fare;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class CreateFareRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
|
||||
@@ -2,27 +2,17 @@
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use App\Contracts\FormRequest;
|
||||
use App\Models\Flight;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class CreateFlightRequest 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()
|
||||
public function rules(): array
|
||||
{
|
||||
return Flight::$rules;
|
||||
}
|
||||
|
||||
19
app/Http/Requests/CreatePageRequest.php
Normal file
19
app/Http/Requests/CreatePageRequest.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use App\Contracts\FormRequest;
|
||||
use App\Models\Page;
|
||||
|
||||
class CreatePageRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return Page::$rules;
|
||||
}
|
||||
}
|
||||
@@ -2,27 +2,17 @@
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use App\Contracts\FormRequest;
|
||||
use App\Models\PirepField;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class CreatePirepFieldRequest 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()
|
||||
public function rules(): array
|
||||
{
|
||||
return PirepField::$rules;
|
||||
}
|
||||
|
||||
@@ -2,29 +2,18 @@
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use App\Contracts\FormRequest;
|
||||
use App\Models\Pirep;
|
||||
use App\Repositories\PirepFieldRepository;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class CreatePirepRequest 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()
|
||||
public function rules(): array
|
||||
{
|
||||
// Don't run validations if it's just being saved
|
||||
$action = strtolower(request('submit', 'submit'));
|
||||
|
||||
@@ -2,27 +2,17 @@
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use App\Contracts\FormRequest;
|
||||
use App\Models\Rank;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class CreateRankRequest 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()
|
||||
public function rules(): array
|
||||
{
|
||||
return Rank::$rules;
|
||||
}
|
||||
|
||||
@@ -2,16 +2,11 @@
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use App\Contracts\FormRequest;
|
||||
use App\Models\Role;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class CreateRoleRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return Role::$rules;
|
||||
|
||||
@@ -2,21 +2,11 @@
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use App\Contracts\FormRequest;
|
||||
use App\Models\Subfleet;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class CreateSubfleetRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
|
||||
@@ -2,21 +2,10 @@
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class CreateUserRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use App\Contracts\FormRequest;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
/**
|
||||
@@ -24,11 +24,6 @@ class ImportRequest extends FormRequest
|
||||
\Validator::make($request->all(), static::$rules)->validate();
|
||||
}
|
||||
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return static::$rules;
|
||||
|
||||
@@ -2,27 +2,17 @@
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use App\Contracts\FormRequest;
|
||||
use App\Models\Aircraft;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UpdateAircraftRequest 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()
|
||||
public function rules(): array
|
||||
{
|
||||
return Aircraft::$rules;
|
||||
}
|
||||
|
||||
@@ -2,27 +2,17 @@
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use App\Contracts\FormRequest;
|
||||
use App\Models\Airline;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UpdateAirlineRequest 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()
|
||||
public function rules(): array
|
||||
{
|
||||
return Airline::$rules;
|
||||
}
|
||||
|
||||
@@ -2,27 +2,17 @@
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use App\Contracts\FormRequest;
|
||||
use App\Models\Airport;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UpdateAirportRequest 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()
|
||||
public function rules(): array
|
||||
{
|
||||
return Airport::$rules;
|
||||
}
|
||||
|
||||
@@ -2,27 +2,17 @@
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use App\Contracts\FormRequest;
|
||||
use App\Models\Award;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UpdateAwardRequest 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()
|
||||
public function rules(): array
|
||||
{
|
||||
return Award::$rules;
|
||||
}
|
||||
|
||||
@@ -2,27 +2,17 @@
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use App\Contracts\FormRequest;
|
||||
use App\Models\Fare;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UpdateFareRequest 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()
|
||||
public function rules(): array
|
||||
{
|
||||
return Fare::$rules;
|
||||
}
|
||||
|
||||
@@ -2,23 +2,10 @@
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use App\Contracts\FormRequest;
|
||||
|
||||
/**
|
||||
* Class CreateFilesRequest
|
||||
*/
|
||||
class UpdateFilesRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
@@ -29,8 +16,6 @@ class UpdateFilesRequest extends FormRequest
|
||||
return [
|
||||
'name' => 'required',
|
||||
'file' => 'nullable|file',
|
||||
|
||||
//'files.*' => 'required|file',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,27 +2,17 @@
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use App\Contracts\FormRequest;
|
||||
use App\Models\Flight;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UpdateFlightRequest 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()
|
||||
public function rules(): array
|
||||
{
|
||||
return Flight::$rules;
|
||||
}
|
||||
|
||||
25
app/Http/Requests/UpdatePageRequest.php
Normal file
25
app/Http/Requests/UpdatePageRequest.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use App\Contracts\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class UpdatePageRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'name' => [
|
||||
'required',
|
||||
Rule::unique('pages')->ignore($this->id, 'id'),
|
||||
],
|
||||
'body' => 'required',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -2,27 +2,17 @@
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use App\Contracts\FormRequest;
|
||||
use App\Models\PirepField;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UpdatePirepFieldRequest 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()
|
||||
public function rules(): array
|
||||
{
|
||||
return PirepField::$rules;
|
||||
}
|
||||
|
||||
@@ -2,29 +2,19 @@
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use App\Contracts\FormRequest;
|
||||
use App\Models\Pirep;
|
||||
use App\Repositories\PirepFieldRepository;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Log;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class UpdatePirepRequest 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()
|
||||
public function rules(): array
|
||||
{
|
||||
// Don't run validations if it's just being saved
|
||||
$action = strtolower(request('submit', 'submit'));
|
||||
|
||||
@@ -2,27 +2,17 @@
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use App\Contracts\FormRequest;
|
||||
use App\Models\Rank;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UpdateRankRequest 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()
|
||||
public function rules(): array
|
||||
{
|
||||
return Rank::$rules;
|
||||
}
|
||||
|
||||
@@ -2,24 +2,14 @@
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use App\Contracts\FormRequest;
|
||||
use App\Models\Role;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
/**
|
||||
* @property array permissions
|
||||
*/
|
||||
class UpdateRoleRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
|
||||
@@ -2,27 +2,17 @@
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use App\Contracts\FormRequest;
|
||||
use App\Models\Subfleet;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UpdateSubfleetRequest 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()
|
||||
public function rules(): array
|
||||
{
|
||||
return Subfleet::$rules;
|
||||
}
|
||||
|
||||
@@ -2,28 +2,18 @@
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use App\Contracts\FormRequest;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use function request;
|
||||
|
||||
class UpdateUserRequest 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()
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = User::$rules;
|
||||
|
||||
|
||||
11
app/Models/Enums/PageType.php
Normal file
11
app/Models/Enums/PageType.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Enums;
|
||||
|
||||
use App\Contracts\Enum;
|
||||
|
||||
class PageType extends Enum
|
||||
{
|
||||
public const HTML = 0;
|
||||
public const MARKDOWN = 1;
|
||||
}
|
||||
@@ -4,6 +4,8 @@ namespace App\Models\Observers;
|
||||
|
||||
/**
|
||||
* Create a slug from a name
|
||||
*
|
||||
* @property object attributes
|
||||
*/
|
||||
class Sluggable
|
||||
{
|
||||
|
||||
41
app/Models/Page.php
Normal file
41
app/Models/Page.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Contracts\Model;
|
||||
|
||||
/**
|
||||
* @property int id
|
||||
* @property string name
|
||||
* @property string slug
|
||||
* @property string icon
|
||||
* @property int type
|
||||
* @property bool public
|
||||
* @property bool enabled
|
||||
* @property string body
|
||||
*/
|
||||
class Page extends Model
|
||||
{
|
||||
public $table = 'pages';
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'slug',
|
||||
'type',
|
||||
'icon',
|
||||
'public',
|
||||
'body',
|
||||
'enabled',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'type' => 'integer',
|
||||
'public' => 'boolean',
|
||||
'enabled' => 'boolean',
|
||||
];
|
||||
|
||||
public static $rules = [
|
||||
'name' => 'required|unique:pages,name',
|
||||
'body' => 'required',
|
||||
];
|
||||
}
|
||||
@@ -18,6 +18,7 @@ use App\Models\Observers\SettingObserver;
|
||||
use App\Models\Observers\Sluggable;
|
||||
use App\Models\Observers\SubfleetObserver;
|
||||
use App\Models\Observers\UserObserver;
|
||||
use App\Models\Page;
|
||||
use App\Models\PirepField;
|
||||
use App\Models\PirepFieldValue;
|
||||
use App\Models\Setting;
|
||||
@@ -38,6 +39,8 @@ class ObserverServiceProviders extends ServiceProvider
|
||||
FlightField::observe(Sluggable::class);
|
||||
FlightFieldValue::observe(Sluggable::class);
|
||||
|
||||
Page::observe(Sluggable::class);
|
||||
|
||||
PirepField::observe(Sluggable::class);
|
||||
PirepFieldValue::observe(Sluggable::class);
|
||||
|
||||
|
||||
@@ -61,6 +61,8 @@ class RouteServiceProvider extends ServiceProvider
|
||||
Route::get('flights/search', 'FlightController@search')->name('flights.search');
|
||||
Route::resource('flights', 'FlightController');
|
||||
|
||||
Route::get('p/{slug}', 'PageController@show')->name('pages.show');
|
||||
|
||||
Route::get('pireps/fares', 'PirepController@fares');
|
||||
Route::post('pireps/{id}/submit', 'PirepController@submit')->name('pireps.submit');
|
||||
|
||||
@@ -285,6 +287,9 @@ class RouteServiceProvider extends ServiceProvider
|
||||
Route::resource('pirepfields', 'PirepFieldController')
|
||||
->middleware('ability:admin,pireps');
|
||||
|
||||
// Pages
|
||||
Route::resource('pages', 'PagesController')->middleware('ability:admin,pages');
|
||||
|
||||
// rankings
|
||||
Route::resource('ranks', 'RankController')->middleware('ability:admin,ranks');
|
||||
Route::match([
|
||||
|
||||
@@ -2,15 +2,16 @@
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Http\Composers\PageLinksComposer;
|
||||
use App\Http\Composers\VersionComposer;
|
||||
use Illuminate\Support\Facades\View;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class ComposerServiceProvider extends ServiceProvider
|
||||
class ViewComposerServiceProvider extends ServiceProvider
|
||||
{
|
||||
public function boot()
|
||||
{
|
||||
// Attach the version number to the admin sidebar
|
||||
View::composer('*', PageLinksComposer::class);
|
||||
View::composer('admin.sidebar', VersionComposer::class);
|
||||
}
|
||||
}
|
||||
21
app/Repositories/PageRepository.php
Normal file
21
app/Repositories/PageRepository.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
use App\Contracts\Repository;
|
||||
use App\Models\Page;
|
||||
use Prettus\Repository\Contracts\CacheableInterface;
|
||||
use Prettus\Repository\Traits\CacheableRepository;
|
||||
|
||||
class PageRepository extends Repository implements CacheableInterface
|
||||
{
|
||||
use CacheableRepository;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function model()
|
||||
{
|
||||
return Page::class;
|
||||
}
|
||||
}
|
||||
@@ -7,12 +7,10 @@ use App\Models\Rank;
|
||||
use Prettus\Repository\Contracts\CacheableInterface;
|
||||
use Prettus\Repository\Traits\CacheableRepository;
|
||||
|
||||
/**
|
||||
* Class RankRepository
|
||||
*/
|
||||
class RankRepository extends Repository implements CacheableInterface
|
||||
{
|
||||
use CacheableRepository;
|
||||
|
||||
protected $fieldSearchable = [
|
||||
'name' => 'like',
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user