-
Notifications
You must be signed in to change notification settings - Fork 0
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
121 changed files
with
5,405 additions
and
553 deletions.
There are no files selected for viewing
122 changes: 122 additions & 0 deletions
122
app/Http/Controllers/Admin/DataManagement/AvailableAppointmentsController.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,122 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\Admin\DataManagement; | ||
|
||
use App\Http\Requests; | ||
use App\Http\Controllers\Controller; | ||
|
||
use App\Http\Requests\AvailableAppointmentRequest; | ||
|
||
use App\Models\AvailableAppointment; | ||
use App\Models\Fixture; | ||
use App\Models\Role; | ||
|
||
class AvailableAppointmentsController extends Controller | ||
{ | ||
|
||
/** | ||
* Display a listing of the resource. | ||
* | ||
* @return mixed | ||
*/ | ||
public function index() | ||
{ | ||
$availableAppointments = AvailableAppointment::paginate(15); | ||
|
||
return view('admin.data-management.available-appointments.index', compact('availableAppointments')); | ||
} | ||
|
||
/** | ||
* Show the form for creating a new resource. | ||
* | ||
* @return mixed | ||
*/ | ||
public function create() | ||
{ | ||
$fixtures = Fixture::all(); | ||
$roles = Role::all(); | ||
|
||
return view('admin.data-management.available-appointments.create', compact('fixtures', 'roles')); | ||
} | ||
|
||
/** | ||
* Store a newly created resource in storage. | ||
* | ||
* @param AvailableAppointmentRequest $request | ||
* @return mixed | ||
*/ | ||
public function store(AvailableAppointmentRequest $request) | ||
{ | ||
AvailableAppointment::create($request->all()); | ||
|
||
\Flash::success('Appointment added!'); | ||
|
||
return redirect('admin/data-management/available-appointments'); | ||
} | ||
|
||
/** | ||
* Display the specified resource. | ||
* | ||
* @param int $id | ||
* | ||
* @return mixed | ||
*/ | ||
public function show($id) | ||
{ | ||
$availableAppointment = AvailableAppointment::findOrFail($id); | ||
|
||
return view('admin.data-management.available-appointments.show', compact('availableAppointment')); | ||
} | ||
|
||
/** | ||
* Show the form for editing the specified resource. | ||
* | ||
* @param int $id | ||
* | ||
* @return mixed | ||
*/ | ||
public function edit($id) | ||
{ | ||
$availableAppointment = AvailableAppointment::findOrFail($id); | ||
|
||
$fixtures = Fixture::all(); | ||
$roles = Role::all(); | ||
|
||
return view('admin.data-management.available-appointments.edit', compact('availableAppointment', 'fixtures', 'roles')); | ||
} | ||
|
||
/** | ||
* Update the specified resource in storage. | ||
* | ||
* @param AvailableAppointmentRequest $request | ||
* @param int $id | ||
* | ||
* @return mixed | ||
*/ | ||
public function update(AvailableAppointmentRequest $request, $id) | ||
{ | ||
$availableAppointment = AvailableAppointment::findOrFail($id); | ||
$availableAppointment->update($request->all()); | ||
|
||
\Flash::success('Appointment updated!'); | ||
|
||
return redirect('admin/data-management/available-appointments'); | ||
} | ||
|
||
/** | ||
* Remove the specified resource from storage. | ||
* | ||
* @param int $id | ||
* | ||
* @return mixed | ||
*/ | ||
public function destroy($id) | ||
{ | ||
AvailableAppointment::destroy($id); | ||
|
||
\Flash::success('Appointment deleted!'); | ||
|
||
return redirect('admin/data-management/available-appointments'); | ||
} | ||
|
||
} |
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
130 changes: 130 additions & 0 deletions
130
app/Http/Controllers/Admin/DataManagement/DivisionsController.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,130 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\Admin\DataManagement; | ||
|
||
use App\Http\Requests; | ||
use App\Http\Controllers\Controller; | ||
|
||
use App\Models\Division; | ||
use Illuminate\Http\Request; | ||
|
||
use App\Models\Season; | ||
|
||
class DivisionsController extends Controller | ||
{ | ||
/** | ||
* Display a listing of the resource. | ||
* | ||
* @return mixed | ||
*/ | ||
public function index() | ||
{ | ||
$divisions = Division::paginate(15); | ||
|
||
return view('admin.data-management.divisions.index', compact('divisions')); | ||
} | ||
|
||
/** | ||
* Show the form for creating a new resource. | ||
* | ||
* @return mixed | ||
*/ | ||
public function create() | ||
{ | ||
return view('admin.data-management.divisions.create', ['seasons' => Season::all()]); | ||
} | ||
|
||
/** | ||
* Store a newly created resource in storage. | ||
* | ||
* @param Request $request | ||
* | ||
* @return mixed | ||
*/ | ||
public function store(Request $request) | ||
{ | ||
$this->validate($request, [ | ||
'season_id' => 'required|exists:seasons,id', | ||
'division' => 'required|unique:divisions,division,NULL,id,season_id,' . $request->get('season_id'), | ||
]); | ||
|
||
Division::create($request->all()); | ||
|
||
\Flash::success('Division added!'); | ||
|
||
return redirect('admin/data-management/divisions'); | ||
} | ||
|
||
/** | ||
* Display the specified resource. | ||
* | ||
* @param int $id | ||
* | ||
* @return mixed | ||
*/ | ||
public function show($id) | ||
{ | ||
$division = Division::findOrFail($id); | ||
|
||
return view('admin.data-management.divisions.show', compact('division')); | ||
} | ||
|
||
/** | ||
* Show the form for editing the specified resource. | ||
* | ||
* @param int $id | ||
* | ||
* @return mixed | ||
*/ | ||
public function edit($id) | ||
{ | ||
$division = Division::findOrFail($id); | ||
$seasons = Season::all(); | ||
|
||
return view('admin.data-management.divisions.edit', compact('division', 'seasons')); | ||
} | ||
|
||
/** | ||
* Update the specified resource in storage. | ||
* | ||
* @param Request $request | ||
* @param int $id | ||
* | ||
* @return mixed | ||
*/ | ||
public function update(Request $request, $id) | ||
{ | ||
$this->validate($request, [ | ||
'season_id' => 'required|exists:seasons,id', | ||
'division' => 'required|unique:divisions,division,NULL,id,season_id,' . $request->get('season_id'), | ||
]); | ||
|
||
$division = Division::findOrFail($id); | ||
$division->update($request->all()); | ||
|
||
\Flash::success('Division updated!'); | ||
|
||
return redirect('admin/data-management/divisions'); | ||
} | ||
|
||
/** | ||
* Remove the specified resource from storage. | ||
* | ||
* @param int $id | ||
* | ||
* @return mixed | ||
*/ | ||
public function destroy($id) | ||
{ | ||
$canBeDeleted = empty(Division::find($id)->fixtures->toArray()); | ||
if ($canBeDeleted) { | ||
Division::destroy($id); | ||
\Flash::success('Division deleted!'); | ||
} else { | ||
\Flash::error('Cannot delete because they are existing fixtures in this division.'); | ||
} | ||
|
||
return redirect('admin/data-management/divisions'); | ||
} | ||
|
||
} |
Oops, something went wrong.