Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
troccoli committed May 14, 2016
2 parents 3859dd1 + da5af88 commit 0b8a88d
Show file tree
Hide file tree
Showing 121 changed files with 5,405 additions and 553 deletions.
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');
}

}
45 changes: 26 additions & 19 deletions app/Http/Controllers/Admin/DataManagement/ClubsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,14 @@

use App\Models\Club;
use Illuminate\Http\Request;
use Carbon\Carbon;
use Session;

class ClubsController extends Controller
{

/**
* Display a listing of the resource.
*
* @return Response
* @return mixed
*/
public function index()
{
Expand All @@ -28,7 +26,7 @@ public function index()
/**
* Show the form for creating a new resource.
*
* @return Response
* @return mixed
*/
public function create()
{
Expand All @@ -38,14 +36,17 @@ public function create()
/**
* Store a newly created resource in storage.
*
* @return Response
* @param Request $request
*
* @return mixed
*/
public function store(Request $request)
{

$this->validate($request, ['club' => 'required|unique:clubs']);

Club::create($request->all());

Flass::success('Club added!');
\Flash::success('Club added!');

return redirect('admin/data-management/clubs');
}
Expand All @@ -55,7 +56,7 @@ public function store(Request $request)
*
* @param int $id
*
* @return Response
* @return mixed
*/
public function show($id)
{
Expand All @@ -69,7 +70,7 @@ public function show($id)
*
* @param int $id
*
* @return Response
* @return mixed
*/
public function edit($id)
{
Expand All @@ -81,17 +82,19 @@ public function edit($id)
/**
* Update the specified resource in storage.
*
* @param int $id
* @param Request $request
* @param int $id
*
* @return Response
* @return mixed
*/
public function update($id, Request $request)
public function update(Request $request, $id)
{

$this->validate($request, ['club' => 'required|unique:clubs,club,' . $id]);

$club = Club::findOrFail($id);
$club->update($request->all());

Flash::success('Club updated!');
\Flash::success('Club updated!');

return redirect('admin/data-management/clubs');
}
Expand All @@ -101,14 +104,18 @@ public function update($id, Request $request)
*
* @param int $id
*
* @return Response
* @return mixed
*/
public function destroy($id)
{
Club::destroy($id);

Flash::success('Club deleted!');

$canBeDeleted = empty(Club::find($id)->teams->toArray());
if ($canBeDeleted) {
Club::destroy($id);
\Flash::success('Club deleted!');
} else {
\Flash::error('Cannot delete because they are existing teams in this club.');
}

return redirect('admin/data-management/clubs');
}

Expand Down
130 changes: 130 additions & 0 deletions app/Http/Controllers/Admin/DataManagement/DivisionsController.php
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');
}

}
Loading

0 comments on commit 0b8a88d

Please sign in to comment.