Add public/private pages #641 (#644)

* Add public/private pages #641

* Cleanup the form requests
This commit is contained in:
Nabeel S 2020-03-28 13:03:52 -04:00 committed by GitHub
parent 4a3ec38919
commit 45873431e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
341 changed files with 9139 additions and 570 deletions

View File

@ -0,0 +1,10 @@
<?php
namespace App\Contracts;
use Illuminate\View\View;
abstract class Composer
{
abstract public function compose(View $view);
}

View File

@ -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 [];
}

View 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');
}
}

View File

@ -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

View 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 [];
}
}

View 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);
}
}

View File

@ -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;

View 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'));
}
}

View File

@ -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
{
/**

View 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]);
}
}

View File

@ -8,11 +8,9 @@ class CommentRequest extends FormRequest
{
public function rules(): array
{
$rules = [
return [
'comment' => 'required',
'created_at' => 'sometimes|date',
];
return $rules;
}
}

View File

@ -4,9 +4,6 @@ namespace App\Http\Requests\Acars;
use App\Contracts\FormRequest;
/**
* Class PrefileRequest
*/
class FieldsRequest extends FormRequest
{
public function rules(): array

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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
{

View File

@ -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';

View File

@ -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.
*

View File

@ -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;
}

View File

@ -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.
*

View File

@ -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;
}

View 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;
}
}

View File

@ -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;
}

View File

@ -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'));

View File

@ -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;
}

View File

@ -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;

View File

@ -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.
*

View File

@ -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.
*

View File

@ -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;

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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',
];
}
}

View 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;
}

View 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',
];
}
}

View File

@ -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;
}

View File

@ -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'));

View File

@ -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;
}

View File

@ -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.
*

View File

@ -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;
}

View File

@ -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;

View 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;
}

View File

@ -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
View 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',
];
}

View File

@ -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);

View File

@ -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([

View File

@ -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);
}
}

View 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;
}
}

View File

@ -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',
];

View File

@ -55,6 +55,7 @@
"symfony/polyfill-iconv": "~1.12",
"theiconic/php-ga-measurement-protocol": "2.7.*",
"tivie/php-os-detector": "~1.1.0",
"vlucas/phpdotenv": "v3.6.0",
"webpatser/laravel-uuid": "~3.0",
"oomphinc/composer-installers-extender": "^1.1"
},

490
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -77,7 +77,7 @@ return [
App\Providers\AuthServiceProvider::class,
App\Providers\BindServiceProviders::class,
App\Providers\BroadcastServiceProvider::class,
App\Providers\ComposerServiceProvider::class,
App\Providers\ViewComposerServiceProvider::class,
App\Providers\CronServiceProvider::class,
App\Providers\DirectiveServiceProvider::class,
App\Providers\EventServiceProvider::class,

View File

@ -16,6 +16,7 @@
"bootstrap": "~4.3",
"bootstrap-sass": "^3.4.1",
"bootstrap3": "npm:bootstrap@~3.4",
"ckeditor4": "ckeditor/ckeditor4-releases#full/latest",
"cookieconsent": "^3.1.0",
"cross-env": "^5.1.6",
"eonasdan-bootstrap-datetimepicker": "^4.17.47",

1879
public/assets/vendor/ckeditor4/CHANGES.md vendored Normal file

File diff suppressed because it is too large Load Diff

1421
public/assets/vendor/ckeditor4/LICENSE.md vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,39 @@
CKEditor 4
==========
Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
https://ckeditor.com - See LICENSE.md for license information.
CKEditor 4 is a text editor to be used inside web pages. It's not a replacement
for desktop text editors like Word or OpenOffice, but a component to be used as
part of web applications and websites.
## Documentation
The full editor documentation is available online at the following address:
https://ckeditor.com/docs/
## Installation
Installing CKEditor is an easy task. Just follow these simple steps:
1. **Download** the latest version from the CKEditor website:
https://ckeditor.com. You should have already completed this step, but be
sure you have the very latest version.
2. **Extract** (decompress) the downloaded file into the root of your website.
**Note:** CKEditor is by default installed in the `ckeditor` folder. You can
place the files in whichever you want though.
## Checking Your Installation
The editor comes with a few sample pages that can be used to verify that
installation proceeded properly. Take a look at the `samples` directory.
To test your installation, just call the following page at your website:
http://<your site>/<CKEditor installation path>/samples/index.html
For example:
http://www.example.com/ckeditor/samples/index.html

View File

@ -0,0 +1,10 @@
/*
Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
(function(a){if("undefined"==typeof a)throw Error("jQuery should be loaded before CKEditor jQuery adapter.");if("undefined"==typeof CKEDITOR)throw Error("CKEditor should be loaded before CKEditor jQuery adapter.");CKEDITOR.config.jqueryOverrideVal="undefined"==typeof CKEDITOR.config.jqueryOverrideVal?!0:CKEDITOR.config.jqueryOverrideVal;a.extend(a.fn,{ckeditorGet:function(){var a=this.eq(0).data("ckeditorInstance");if(!a)throw"CKEditor is not initialized yet, use ckeditor() with a callback.";return a},
ckeditor:function(g,e){if(!CKEDITOR.env.isCompatible)throw Error("The environment is incompatible.");if(!a.isFunction(g)){var m=e;e=g;g=m}var k=[];e=e||{};this.each(function(){var b=a(this),c=b.data("ckeditorInstance"),f=b.data("_ckeditorInstanceLock"),h=this,l=new a.Deferred;k.push(l.promise());if(c&&!f)g&&g.apply(c,[this]),l.resolve();else if(f)c.once("instanceReady",function(){setTimeout(function d(){c.element?(c.element.$==h&&g&&g.apply(c,[h]),l.resolve()):setTimeout(d,100)},0)},null,null,9999);
else{if(e.autoUpdateElement||"undefined"==typeof e.autoUpdateElement&&CKEDITOR.config.autoUpdateElement)e.autoUpdateElementJquery=!0;e.autoUpdateElement=!1;b.data("_ckeditorInstanceLock",!0);c=a(this).is("textarea")?CKEDITOR.replace(h,e):CKEDITOR.inline(h,e);b.data("ckeditorInstance",c);c.on("instanceReady",function(e){var d=e.editor;setTimeout(function n(){if(d.element){e.removeListener();d.on("dataReady",function(){b.trigger("dataReady.ckeditor",[d])});d.on("setData",function(a){b.trigger("setData.ckeditor",
[d,a.data])});d.on("getData",function(a){b.trigger("getData.ckeditor",[d,a.data])},999);d.on("destroy",function(){b.trigger("destroy.ckeditor",[d])});d.on("save",function(){a(h.form).submit();return!1},null,null,20);if(d.config.autoUpdateElementJquery&&b.is("textarea")&&a(h.form).length){var c=function(){b.ckeditor(function(){d.updateElement()})};a(h.form).submit(c);a(h.form).bind("form-pre-serialize",c);b.bind("destroy.ckeditor",function(){a(h.form).unbind("submit",c);a(h.form).unbind("form-pre-serialize",
c)})}d.on("destroy",function(){b.removeData("ckeditorInstance")});b.removeData("_ckeditorInstanceLock");b.trigger("instanceReady.ckeditor",[d]);g&&g.apply(d,[h]);l.resolve()}else setTimeout(n,100)},0)},null,null,9999)}});var f=new a.Deferred;this.promise=f.promise();a.when.apply(this,k).then(function(){f.resolve()});this.editor=this.eq(0).data("ckeditorInstance");return this}});CKEDITOR.config.jqueryOverrideVal&&(a.fn.val=CKEDITOR.tools.override(a.fn.val,function(g){return function(e){if(arguments.length){var m=
this,k=[],f=this.each(function(){var b=a(this),c=b.data("ckeditorInstance");if(b.is("textarea")&&c){var f=new a.Deferred;c.setData(e,function(){f.resolve()});k.push(f.promise());return!0}return g.call(b,e)});if(k.length){var b=new a.Deferred;a.when.apply(this,k).done(function(){b.resolveWith(m)});return b.promise()}return f}var f=a(this).eq(0),c=f.data("ckeditorInstance");return f.is("textarea")&&c?c.getData():g.call(f)}}))})(window.jQuery);

View File

@ -0,0 +1,168 @@
/**
* @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/license
*/
/**
* This file was added automatically by CKEditor builder.
* You may re-use it at any time to build CKEditor again.
*
* If you would like to build CKEditor online again
* (for example to upgrade), visit one the following links:
*
* (1) https://ckeditor.com/cke4/builder
* Visit online builder to build CKEditor from scratch.
*
* (2) https://ckeditor.com/cke4/builder/3b54fd1f22dcd13ebe2a3f52d6f8cc05
* Visit online builder to build CKEditor, starting with the same setup as before.
*
* (3) https://ckeditor.com/cke4/builder/download/3b54fd1f22dcd13ebe2a3f52d6f8cc05
* Straight download link to the latest version of CKEditor (Optimized) with the same setup as before.
*
* NOTE:
* This file is not used by CKEditor, you may remove it.
* Changing this file will not change your CKEditor configuration.
*/
var CKBUILDER_CONFIG = {
skin: 'moono-lisa',
preset: 'standard',
ignore: [
'.DS_Store',
'.bender',
'.editorconfig',
'.gitattributes',
'.gitignore',
'.idea',
'.jscsrc',
'.jshintignore',
'.jshintrc',
'.mailmap',
'.npm',
'.travis.yml',
'bender-err.log',
'bender-out.log',
'bender.ci.js',
'bender.js',
'dev',
'gruntfile.js',
'less',
'node_modules',
'package.json',
'tests'
],
plugins : {
'a11yhelp' : 1,
'about' : 1,
'basicstyles' : 1,
'blockquote' : 1,
'clipboard' : 1,
'contextmenu' : 1,
'elementspath' : 1,
'enterkey' : 1,
'entities' : 1,
'filebrowser' : 1,
'floatingspace' : 1,
'format' : 1,
'horizontalrule' : 1,
'htmlwriter' : 1,
'image' : 1,
'indentlist' : 1,
'link' : 1,
'list' : 1,
'magicline' : 1,
'maximize' : 1,
'pastefromgdocs' : 1,
'pastefromword' : 1,
'pastetext' : 1,
'pastetools' : 1,
'removeformat' : 1,
'resize' : 1,
'scayt' : 1,
'showborders' : 1,
'sourcearea' : 1,
'specialchar' : 1,
'stylescombo' : 1,
'tab' : 1,
'table' : 1,
'tableselection' : 1,
'tabletools' : 1,
'toolbar' : 1,
'undo' : 1,
'uploadimage' : 1,
'wsc' : 1,
'wysiwygarea' : 1
},
languages : {
'af' : 1,
'ar' : 1,
'az' : 1,
'bg' : 1,
'bn' : 1,
'bs' : 1,
'ca' : 1,
'cs' : 1,
'cy' : 1,
'da' : 1,
'de' : 1,
'de-ch' : 1,
'el' : 1,
'en' : 1,
'en-au' : 1,
'en-ca' : 1,
'en-gb' : 1,
'eo' : 1,
'es' : 1,
'es-mx' : 1,
'et' : 1,
'eu' : 1,
'fa' : 1,
'fi' : 1,
'fo' : 1,
'fr' : 1,
'fr-ca' : 1,
'gl' : 1,
'gu' : 1,
'he' : 1,
'hi' : 1,
'hr' : 1,
'hu' : 1,
'id' : 1,
'is' : 1,
'it' : 1,
'ja' : 1,
'ka' : 1,
'km' : 1,
'ko' : 1,
'ku' : 1,
'lt' : 1,
'lv' : 1,
'mk' : 1,
'mn' : 1,
'ms' : 1,
'nb' : 1,
'nl' : 1,
'no' : 1,
'oc' : 1,
'pl' : 1,
'pt' : 1,
'pt-br' : 1,
'ro' : 1,
'ru' : 1,
'si' : 1,
'sk' : 1,
'sl' : 1,
'sq' : 1,
'sr' : 1,
'sr-latn' : 1,
'sv' : 1,
'th' : 1,
'tr' : 1,
'tt' : 1,
'ug' : 1,
'uk' : 1,
'vi' : 1,
'zh' : 1,
'zh-cn' : 1
}
};

1267
public/assets/vendor/ckeditor4/ckeditor.js vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,38 @@
/**
* @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see https://ckeditor.com/legal/ckeditor-oss-license
*/
CKEDITOR.editorConfig = function( config ) {
// Define changes to default configuration here.
// For complete reference see:
// https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html
// The toolbar groups arrangement, optimized for two toolbar rows.
config.toolbarGroups = [
{ name: 'clipboard', groups: [ 'clipboard', 'undo' ] },
{ name: 'editing', groups: [ 'find', 'selection', 'spellchecker' ] },
{ name: 'links' },
{ name: 'insert' },
{ name: 'forms' },
{ name: 'tools' },
{ name: 'document', groups: [ 'mode', 'document', 'doctools' ] },
{ name: 'others' },
'/',
{ name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ] },
{ name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align', 'bidi' ] },
{ name: 'styles' },
{ name: 'colors' },
{ name: 'about' }
];
// Remove some buttons provided by the standard plugins, which are
// not needed in the Standard(s) toolbar.
config.removeButtons = 'Underline,Subscript,Superscript';
// Set the most common block elements.
config.format_tags = 'p;h1;h2;h3;pre';
// Simplify the dialog windows.
config.removeDialogTabs = 'image:advanced;link:advanced';
};

View File

@ -0,0 +1,208 @@
/*
Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
body
{
/* Font */
/* Emoji fonts are added to visualise them nicely in Internet Explorer. */
font-family: sans-serif, Arial, Verdana, "Trebuchet MS", "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
font-size: 12px;
/* Text color */
color: #333;
/* Remove the background color to make it transparent. */
background-color: #fff;
margin: 20px;
}
.cke_editable
{
font-size: 13px;
line-height: 1.6;
/* Fix for missing scrollbars with RTL texts. (#10488) */
word-wrap: break-word;
}
blockquote
{
font-style: italic;
font-family: Georgia, Times, "Times New Roman", serif;
padding: 2px 0;
border-style: solid;
border-color: #ccc;
border-width: 0;
}
.cke_contents_ltr blockquote
{
padding-left: 20px;
padding-right: 8px;
border-left-width: 5px;
}
.cke_contents_rtl blockquote
{
padding-left: 8px;
padding-right: 20px;
border-right-width: 5px;
}
a
{
color: #0782C1;
}
ol,ul,dl
{
/* IE7: reset rtl list margin. (#7334) */
*margin-right: 0px;
/* Preserved spaces for list items with text direction different than the list. (#6249,#8049)*/
padding: 0 40px;
}
h1,h2,h3,h4,h5,h6
{
font-weight: normal;
line-height: 1.2;
}
hr
{
border: 0px;
border-top: 1px solid #ccc;
}
img.right
{
border: 1px solid #ccc;
float: right;
margin-left: 15px;
padding: 5px;
}
img.left
{
border: 1px solid #ccc;
float: left;
margin-right: 15px;
padding: 5px;
}
pre
{
white-space: pre-wrap; /* CSS 2.1 */
word-wrap: break-word; /* IE7 */
-moz-tab-size: 4;
tab-size: 4;
}
.marker
{
background-color: Yellow;
}
span[lang]
{
font-style: italic;
}
figure
{
text-align: center;
outline: solid 1px #ccc;
background: rgba(0,0,0,0.05);
padding: 10px;
margin: 10px 20px;
display: inline-block;
}
figure > figcaption
{
text-align: center;
display: block; /* For IE8 */
}
a > img {
padding: 1px;
margin: 1px;
border: none;
outline: 1px solid #0782C1;
}
/* Widget Styles */
.code-featured
{
border: 5px solid red;
}
.math-featured
{
padding: 20px;
box-shadow: 0 0 2px rgba(200, 0, 0, 1);
background-color: rgba(255, 0, 0, 0.05);
margin: 10px;
}
.image-clean
{
border: 0;
background: none;
padding: 0;
}
.image-clean > figcaption
{
font-size: .9em;
text-align: right;
}
.image-grayscale
{
background-color: white;
color: #666;
}
.image-grayscale img, img.image-grayscale
{
filter: grayscale(100%);
}
.embed-240p
{
max-width: 426px;
max-height: 240px;
margin:0 auto;
}
.embed-360p
{
max-width: 640px;
max-height: 360px;
margin:0 auto;
}
.embed-480p
{
max-width: 854px;
max-height: 480px;
margin:0 auto;
}
.embed-720p
{
max-width: 1280px;
max-height: 720px;
margin:0 auto;
}
.embed-1080p
{
max-width: 1920px;
max-height: 1080px;
margin:0 auto;
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Some files were not shown because too many files have changed in this diff Show More