Merge branch 'master' of https://github.com/sebathefox/skolehjem-webapp into master
Conflicts: skolehjem/app/Http/Controllers/RootController.php
This commit is contained in:
@@ -15,8 +15,7 @@ class ContactController extends Controller
|
||||
$this->middleware([ "auth" ]);
|
||||
$this->middleware([ "lang" ]);
|
||||
|
||||
$this->middleware([ "check.auth:contact.list" ])->only("index");
|
||||
$this->middleware([ "check.auth:contact.show" ])->only("show");
|
||||
$this->middleware([ "check.auth:contact.show" ])->only("show", "index");
|
||||
$this->middleware([ "check.auth:contact.create" ])->only("create", "store");
|
||||
$this->middleware([ "check.auth:contact.edit" ])->only("edit", "update");
|
||||
$this->middleware([ "check.auth:contact.delete" ])->only("delete");
|
||||
|
||||
@@ -11,6 +11,7 @@ use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
date_default_timezone_set('Europe/Copenhagen');
|
||||
|
||||
class EventController extends Controller
|
||||
{
|
||||
@@ -19,8 +20,7 @@ class EventController extends Controller
|
||||
$this->middleware([ "auth" ]);
|
||||
$this->middleware([ "lang" ]);
|
||||
|
||||
$this->middleware([ "check.auth:event.list" ])->only("index");
|
||||
$this->middleware([ "check.auth:event.show" ])->only("show");
|
||||
$this->middleware([ "check.auth:event.show" ])->only("show", "index");
|
||||
$this->middleware([ "check.auth:event.create" ])->only("create", "store");
|
||||
$this->middleware([ "check.auth:event.edit" ])->only("edit", "update");
|
||||
$this->middleware([ "check.auth:event.delete" ])->only("delete");
|
||||
@@ -33,12 +33,15 @@ class EventController extends Controller
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
DB::table('user_events')
|
||||
->where('event_id')
|
||||
->delete();
|
||||
DB::table('events')
|
||||
->where('events.date', '<=', date('Y-m-d H:i', strtotime('-1 day')))
|
||||
->delete();
|
||||
$eventsToDelete = Event::query()->get();
|
||||
|
||||
foreach ($eventsToDelete as $event) {
|
||||
if (date('Y-m-d H:i', strtotime('-1 day')) >= date('Y-m-d H:i', strtotime($event->date))) {
|
||||
UserEvent::query()->where('event_id', '=', $event->id)->delete();
|
||||
|
||||
$event->delete();
|
||||
}
|
||||
}
|
||||
|
||||
$events = Event::query()->orderBY('date' , 'asc')->paginate($request->input("limit", 20));
|
||||
|
||||
@@ -62,7 +65,7 @@ class EventController extends Controller
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
@@ -103,7 +106,6 @@ class EventController extends Controller
|
||||
|
||||
return redirect()->route('events.index', ['events' => $events]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -234,9 +236,8 @@ class EventController extends Controller
|
||||
$userEvent->delete();
|
||||
}
|
||||
|
||||
$news = News::query()->where("type_id", "=", "3")->where("arrangement_id", "=", $event->id)->first();
|
||||
if($news !== null)
|
||||
$news->delete();
|
||||
$news = News::query()->join('news_types', 'news_types.id', '=', 'news.type_id')->where("type", "=", "Activity")->where("arrangement_id", "=", $id);
|
||||
$news->delete();
|
||||
|
||||
$event->delete();
|
||||
|
||||
|
||||
@@ -15,8 +15,7 @@ class FeedbackController extends Controller
|
||||
$this->middleware([ "auth" ]);
|
||||
$this->middleware([ "lang" ]);
|
||||
|
||||
$this->middleware([ "check.auth:feedback.list" ])->only("index");
|
||||
$this->middleware([ "check.auth:feedback.show" ])->only("show");
|
||||
$this->middleware([ "check.auth:feedback.show" ])->only("show", "index");
|
||||
$this->middleware([ "check.auth:feedback.create" ])->only("create", "store");
|
||||
$this->middleware([ "check.auth:feedback.edit" ])->only("edit", "update");
|
||||
$this->middleware([ "check.auth:feedback.delete" ])->only("delete");
|
||||
|
||||
@@ -15,8 +15,7 @@ class GuideController extends Controller
|
||||
$this->middleware([ "auth" ]);
|
||||
$this->middleware([ "lang" ]);
|
||||
|
||||
$this->middleware([ "check.auth:guides.list" ])->only("index");
|
||||
$this->middleware([ "check.auth:guides.show" ])->only("show");
|
||||
$this->middleware([ "check.auth:guides.show" ])->only("show", "index");
|
||||
$this->middleware([ "check.auth:guides.create" ])->only("create", "store");
|
||||
$this->middleware([ "check.auth:guides.edit" ])->only("edit", "update");
|
||||
$this->middleware([ "check.auth:guides.delete" ])->only("delete");
|
||||
@@ -160,17 +159,18 @@ class GuideController extends Controller
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param Guide $guide
|
||||
* @param Guide $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy($guide)
|
||||
public function destroy($id)
|
||||
{
|
||||
$guide = Guide::find($guide);
|
||||
$news = News::query()->where("type_id", "=", "4")->where("arrangement_id", "=", $guide->id)->first();
|
||||
|
||||
if($news !== null)
|
||||
$news->delete();
|
||||
// Find the guide you want to remove
|
||||
$guide = Guide::find($id);
|
||||
// Find the news the you made when creating the guide (if there is a news)
|
||||
$news = News::query()->join('news_types', 'news_types.id', '=', 'news.type_id')->where("type", "=", "Guide")->where("arrangement_id", "=", $id);
|
||||
|
||||
//Delete the news or/and guide
|
||||
$news->delete();
|
||||
$guide->delete();
|
||||
|
||||
|
||||
|
||||
@@ -17,8 +17,7 @@ class LocationController extends Controller
|
||||
$this->middleware([ "auth" ]);
|
||||
$this->middleware([ "lang" ]);
|
||||
|
||||
$this->middleware([ "check.auth:locations.list" ])->only("index");
|
||||
$this->middleware([ "check.auth:locations.show" ])->only("show");
|
||||
$this->middleware([ "check.auth:locations.show" ])->only("show", "index");
|
||||
$this->middleware([ "check.auth:locations.create" ])->only("create", "store");
|
||||
$this->middleware([ "check.auth:locations.edit" ])->only("edit", "update");
|
||||
$this->middleware([ "check.auth:locations.delete" ])->only("delete");
|
||||
|
||||
@@ -22,8 +22,7 @@ class MenuPlanController extends Controller
|
||||
$this->middleware([ "auth" ]);
|
||||
$this->middleware([ "lang" ]);
|
||||
|
||||
$this->middleware([ "check.auth:menuplan.list" ])->only("index");
|
||||
$this->middleware([ "check.auth:menuplan.show" ])->only("show");
|
||||
$this->middleware([ "check.auth:menuplan.show" ])->only("show", "index");
|
||||
$this->middleware([ "check.auth:menuplan.create" ])->only("create", "store");
|
||||
$this->middleware([ "check.auth:menuplan.edit" ])->only("edit", "update");
|
||||
$this->middleware([ "check.auth:menuplan.delete" ])->only("delete");
|
||||
@@ -194,7 +193,13 @@ class MenuPlanController extends Controller
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
// Find the menu you want to remove
|
||||
$menuplan = MenuPlan::find($id);
|
||||
// Find the news the you made when creating the menu (if there is a news)
|
||||
$news = News::query()->join('news_types', 'news_types.id', '=', 'news.type_id')->where('type', '=', 'Menu')->where('arrangement_id', '=', $id);
|
||||
|
||||
//Delete the news or/and menu
|
||||
$news->delete();
|
||||
$menuplan->delete();
|
||||
return redirect()->route("menu-plans.index");
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Event;
|
||||
use App\Helpers;
|
||||
use App\News;
|
||||
use App\User;
|
||||
@@ -17,8 +18,7 @@ class NewsController extends Controller
|
||||
$this->middleware([ "auth" ]);
|
||||
$this->middleware([ "lang" ]);
|
||||
|
||||
$this->middleware([ "check.auth:news.list" ])->only("index");
|
||||
$this->middleware([ "check.auth:news.show" ])->only("show");
|
||||
$this->middleware([ "check.auth:news.show" ])->only("show", "index");
|
||||
$this->middleware([ "check.auth:news.create" ])->only("create", "store");
|
||||
$this->middleware([ "check.auth:news.edit" ])->only("edit", "update");
|
||||
$this->middleware([ "check.auth:news.delete" ])->only("delete");
|
||||
|
||||
@@ -13,8 +13,7 @@ class ResourceCategoryController extends Controller
|
||||
$this->middleware([ "auth" ]);
|
||||
$this->middleware([ "lang" ]);
|
||||
|
||||
$this->middleware([ "check.auth:resource.category.list" ])->only("index");
|
||||
$this->middleware([ "check.auth:resource.category.show" ])->only("show");
|
||||
$this->middleware([ "check.auth:resource.category.show" ])->only("show", "index");
|
||||
$this->middleware([ "check.auth:resource.category.create" ])->only("create", "store");
|
||||
$this->middleware([ "check.auth:resource.category.edit" ])->only("edit", "update");
|
||||
$this->middleware([ "check.auth:resource.category.delete" ])->only("delete");
|
||||
|
||||
@@ -16,8 +16,7 @@ class ResourceController extends Controller
|
||||
$this->middleware([ "auth" ]);
|
||||
$this->middleware([ "lang" ]);
|
||||
|
||||
$this->middleware([ "check.auth:resource.list" ])->only("index");
|
||||
$this->middleware([ "check.auth:resource.show" ])->only("show");
|
||||
$this->middleware([ "check.auth:resource.show" ])->only("show", "index");
|
||||
$this->middleware([ "check.auth:resource.create" ])->only("create", "store");
|
||||
$this->middleware([ "check.auth:resource.edit" ])->only("edit", "update");
|
||||
$this->middleware([ "check.auth:resource.delete" ])->only("delete");
|
||||
|
||||
@@ -13,8 +13,7 @@ class ResourceExtensionController extends Controller
|
||||
$this->middleware([ "auth" ]);
|
||||
$this->middleware([ "lang" ]);
|
||||
|
||||
$this->middleware([ "check.auth:resource.extension.list" ])->only("index");
|
||||
$this->middleware([ "check.auth:resource.extension.show" ])->only("show");
|
||||
$this->middleware([ "check.auth:resource.extension.show" ])->only("show", "index");
|
||||
$this->middleware([ "check.auth:resource.extension.create" ])->only("create", "store");
|
||||
$this->middleware([ "check.auth:resource.extension.edit" ])->only("edit", "update");
|
||||
$this->middleware([ "check.auth:resource.extension.delete" ])->only("delete");
|
||||
|
||||
@@ -8,15 +8,14 @@ use Illuminate\Support\Facades\DB;
|
||||
use Spatie\Permission\Models\Role;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
|
||||
class rolesController extends Controller
|
||||
class RolesController extends Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware([ "auth" ]);
|
||||
$this->middleware([ "lang" ]);
|
||||
|
||||
$this->middleware([ "check.auth:roles.list" ])->only("index");
|
||||
$this->middleware([ "check.auth:roles.show" ])->only("show");
|
||||
$this->middleware([ "check.auth:roles.show" ])->only("show", "index");
|
||||
$this->middleware([ "check.auth:roles.create" ])->only("create", "store");
|
||||
$this->middleware([ "check.auth:roles.edit" ])->only("edit", "update");
|
||||
$this->middleware([ "check.auth:roles.delete" ])->only("delete");
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Event;
|
||||
use App\News;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
@@ -17,6 +18,15 @@ class RootController extends Controller
|
||||
public function index() {
|
||||
$perPage = 5;
|
||||
|
||||
$newsCollection = News::query()->orderBy('id', 'desc')->paginate($perPage);
|
||||
|
||||
foreach ($newsCollection as $new)
|
||||
{
|
||||
if($new->type_id == 3)
|
||||
if(Event::query()->where('id', '=', $new->arrangement_id)->first() == null)
|
||||
$new->delete();
|
||||
}
|
||||
|
||||
if(auth()->user()->can('admin.panel.show')) {
|
||||
if(Response::detect("root.index")->name() == "admin.root.index")
|
||||
return view("admin.root.index");
|
||||
|
||||
@@ -23,11 +23,11 @@ class UserController extends Controller
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware([ "auth" ])->only("logout");
|
||||
|
||||
$this->middleware([ "guest" ])->only("login");
|
||||
$this->middleware([ "lang" ])->except(["login", "showLogin", "showForgot", "forgot"]);
|
||||
|
||||
$this->middleware([ "check.auth:user.list" ])->only("index");
|
||||
$this->middleware([ "check.auth:user.show" ])->only("show");
|
||||
$this->middleware([ "check.auth:user.show" ])->only("show", "index");
|
||||
$this->middleware([ "check.auth:user.create" ])->only("create");
|
||||
$this->middleware([ "check.auth:user.edit" ])->only(["edit", "update"]);
|
||||
$this->middleware([ "check.auth:user.delete" ])->only("delete");
|
||||
|
||||
@@ -20,8 +20,7 @@ class WashingMachineController extends Controller
|
||||
$this->middleware([ "auth" ]);
|
||||
$this->middleware([ "lang" ]);
|
||||
|
||||
$this->middleware([ "check.auth:washing.machine.list" ])->only("index");
|
||||
$this->middleware([ "check.auth:washing.machine.show" ])->only("show");
|
||||
$this->middleware([ "check.auth:washing.machine.show" ])->only("show", "index");
|
||||
$this->middleware([ "check.auth:washing.machine.create" ])->only("create", "store");
|
||||
$this->middleware([ "check.auth:washing.machine.edit" ])->only("edit", "update");
|
||||
$this->middleware([ "check.auth:washing.machine.delete" ])->only("delete");
|
||||
|
||||
@@ -24,8 +24,7 @@ class WashingReservationController extends Controller
|
||||
$this->middleware([ "auth" ]);
|
||||
$this->middleware([ "lang" ]);
|
||||
|
||||
$this->middleware([ "check.auth:washing.machine.reservation.list" ])->only(["index", "appindex"]);
|
||||
$this->middleware([ "check.auth:washing.machine.reservation.show" ])->only("show");
|
||||
$this->middleware([ "check.auth:washing.machine.reservation.show" ])->only("show", "index", "appindex");
|
||||
$this->middleware([ "check.auth:washing.machine.reservation.create" ])->only("create", "store");
|
||||
$this->middleware([ "check.auth:washing.machine.reservation.edit" ])->only("edit", "update");
|
||||
$this->middleware([ "check.auth:washing.machine.reservation.delete" ])->only("delete");
|
||||
@@ -266,7 +265,7 @@ class WashingReservationController extends Controller
|
||||
{
|
||||
WashingReservation::query()->where('time', '<', date('Y-m-d H:i:s', strtotime('-1 hour')))->delete();
|
||||
|
||||
$reservations = WashingReservation::query()->where("user_id", "=", auth()->user()->id)->orderBY('time' , 'asc')->paginate($request->query("limit", 20));
|
||||
$reservations = WashingReservation::query()->join('washing_machines', 'washing_machines.id', '=', 'washing_reservations.machine_id')->join('locations', 'locations.id', '=', 'washing_machines.location_id')->where("user_id", "=", auth()->user()->id)->orderBY('time' , 'asc')->paginate($request->query("limit", 20));
|
||||
|
||||
return Response::detect("washing-reservations.index", [ "reservations" => $reservations]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user