-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
7,561 additions
and
6,533 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 108 additions & 0 deletions
108
app/Http/Controllers/EventLink/EventLinkAdminController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
Oops, something went wrong.