Skip to content

Commit

Permalink
Merge branch 'release/2.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
daveroverts committed Jan 29, 2021
2 parents fe7735a + e12dd15 commit 4840139
Show file tree
Hide file tree
Showing 21 changed files with 7,561 additions and 6,533 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [v2.2.0](https://github.com/daveroverts/bmac/compare/v2.1.0.e...v2.2.0) - 2021-01-29

### Added
- Added `EventLink`, a copy of `AirportLink`

### Removed
- Removed old static oceanic briefing, use the new `EventLink` for that.

## [v2.1.0.e](https://github.com/daveroverts/bmac/compare/v2.1.0.d...v2.1.0.e) - 2021-01-05

### Changed
Expand Down
108 changes: 108 additions & 0 deletions app/Http/Controllers/EventLink/EventLinkAdminController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
<?php

namespace App\Http\Controllers\EventLink;

use App\Models\Event;
use App\Models\EventLink;
use App\Models\AirportLinkType;
use App\Policies\EventLinkPolicy;
use App\Http\Controllers\AdminController;
use App\Http\Requests\EventLink\Admin\StoreEventLink;
use App\Http\Requests\EventLink\Admin\UpdateEventLink;

class EventLinkAdminController extends AdminController
{
/**
* Instantiate a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->authorizeResource(EventLinkPolicy::class, 'eventLink');
}

/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$eventLinks = EventLink::orderBy('event_id', 'asc')
->with(['event', 'type'])
->paginate();
return view('eventLink.admin.overview', compact('eventLinks'));
}

/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create(Event $event)
{
$eventLink = new EventLink();
$eventLinkTypes = AirportLinkType::all();
$events = Event::where('endEvent', '>', now())
->orderBy('startEvent')
->get();
return view('eventLink.admin.form', compact('eventLink', 'eventLinkTypes', 'events'));
}

/**
* Store a newly created resource in storage.
*
* @param StoreEventLink $request
* @return \Illuminate\Http\Response
*/
public function store(StoreEventLink $request)
{
$eventLink = EventLink::create($request->validated());
flashMessage(
'success',
'Done',
$eventLink->type->name . ' item has been added for ' . $eventLink->event->name
);
return redirect(route('admin.eventLinks.index'));
}

/**
* Show the form for editing the specified resource.
*
* @param \App\Models\EventLink $eventLink
* @return \Illuminate\Http\Response
*/
public function edit(EventLink $eventLink)
{
$eventLinkTypes = AirportLinkType::all();
return view('eventLink.admin.form', compact('eventLink', 'eventLinkTypes'));
}

/**
* Update the specified resource in storage.
*
* @param UpdateAirportLink $request
* @param \App\Models\EventLink $eventLink
* @return \Illuminate\Http\Response
*/
public function update(UpdateEventLink $request, EventLink $eventLink)
{
$eventLink->update($request->validated());
flashMessage('success', 'Done', 'Link has been updated');
return redirect(route('admin.eventLinks.index'));
}

/**
* Remove the specified resource from storage.
*
* @param \App\Models\EventLink $eventLink
* @return \Illuminate\Http\Response
*/
public function destroy(EventLink $eventLink)
{
$eventLink->delete();
flashMessage('success', 'Event link deleted', 'Event link has been deleted');
return back();
}
}
23 changes: 23 additions & 0 deletions app/Http/Requests/EventLink/Admin/StoreEventLink.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace App\Http\Requests\EventLink\Admin;

use App\Http\Requests\Request;

class StoreEventLink extends Request
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'event_link_type_id' => 'exists:airport_link_types,id',
'event_id' => 'exists:events,id',
'name' => 'nullable|string',
'url' => 'required|url',
];
}
}
22 changes: 22 additions & 0 deletions app/Http/Requests/EventLink/Admin/UpdateEventLink.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace App\Http\Requests\EventLink\Admin;

use App\Http\Requests\Request;

class UpdateEventLink extends Request
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'event_link_type_id' => 'exists:airport_link_types,id',
'name' => 'nullable|string',
'url' => 'required|url',
];
}
}
1 change: 1 addition & 0 deletions app/Models/AirportLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public function airport()
return $this->hasOne(Airport::class, 'id', 'airport_id');
}

// TODO Or do we want to create a LinkType model / collection?
public function type()
{
return $this->hasOne(AirportLinkType::class, 'id', 'airportLinkType_id');
Expand Down
10 changes: 8 additions & 2 deletions app/Models/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

namespace App\Models;

use Cviebrock\EloquentSluggable\Sluggable;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use App\Models\EventLink;
use Illuminate\Database\Eloquent\Model;
use Cviebrock\EloquentSluggable\Sluggable;
use Spatie\Activitylog\Traits\LogsActivity;
use Illuminate\Database\Eloquent\Factories\HasFactory;

/**
* App\Models\Event
Expand Down Expand Up @@ -134,6 +135,11 @@ public function airportArr()
return $this->hasOne(Airport::class, 'id', 'arr');
}

public function links()
{
return $this->hasMany(EventLink::class);
}

public function faqs()
{
return $this->belongsToMany(Faq::class);
Expand Down
37 changes: 37 additions & 0 deletions app/Models/EventLink.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

namespace App\Models;

use App\Models\Event;
use App\Models\AirportLinkType;
use Illuminate\Database\Eloquent\Model;
use Spatie\Activitylog\Traits\LogsActivity;
use Illuminate\Database\Eloquent\Factories\HasFactory;

class EventLink extends Model
{
use HasFactory;
use LogsActivity;

/**
* The attributes that aren't mass assignable.
*
* @var array
*/
protected $guarded = ['id'];

protected static $logAttributes = ['*'];
protected static $logOnlyDirty = true;

public function event()
{
return $this->belongsTo(Event::class);
}

// TODO Do we want to split this to a dedicated EventLinkType?
// TODO Or do we want to create a LinkType model / collection?
public function type()
{
return $this->belongsTo(AirportLinkType::class, 'event_link_type_id');
}
}
94 changes: 94 additions & 0 deletions app/Policies/EventLinkPolicy.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<?php

namespace App\Policies;

use App\Models\EventLink;
use App\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;

class EventLinkPolicy
{
use HandlesAuthorization;

/**
* Determine whether the user can view any models.
*
* @param \App\Models\User $user
* @return mixed
*/
public function viewAny(User $user)
{
return false;
}

/**
* Determine whether the user can view the model.
*
* @param \App\Models\User $user
* @param \App\Models\EventLink $eventLink
* @return mixed
*/
public function view(User $user, EventLink $eventLink)
{
return false;
}

/**
* Determine whether the user can create models.
*
* @param \App\Models\User $user
* @return mixed
*/
public function create(User $user)
{
return false;
}

/**
* Determine whether the user can update the model.
*
* @param \App\Models\User $user
* @param \App\Models\EventLink $eventLink
* @return mixed
*/
public function update(User $user, EventLink $eventLink)
{
return false;
}

/**
* Determine whether the user can delete the model.
*
* @param \App\Models\User $user
* @param \App\Models\EventLink $eventLink
* @return mixed
*/
public function delete(User $user, EventLink $eventLink)
{
return false;
}

/**
* Determine whether the user can restore the model.
*
* @param \App\Models\User $user
* @param \App\Models\EventLink $eventLink
* @return mixed
*/
public function restore(User $user, EventLink $eventLink)
{
return false;
}

/**
* Determine whether the user can permanently delete the model.
*
* @param \App\Models\User $user
* @param \App\Models\EventLink $eventLink
* @return mixed
*/
public function forceDelete(User $user, EventLink $eventLink)
{
return false;
}
}
Loading

0 comments on commit 4840139

Please sign in to comment.