v1.1.0 - Washing machines and locations is on the same pages now, made bruger roles immortal so you cant delete it or edit it

This commit is contained in:
Neerholt 2020-09-10 10:39:07 +02:00
parent 1030bcc13f
commit e08a8aa509
4 changed files with 53 additions and 19 deletions

View File

@ -64,11 +64,11 @@ class LocationController extends Controller
// If there already is a washing machine with that name, then don't add it // If there already is a washing machine with that name, then don't add it
if (count($locations) > 0) if (count($locations) > 0)
return redirect()->route("locations.index"); return redirect()->route("washing-machines.index");
else { // Else - Add it else { // Else - Add it
$location->save(); $location->save();
$locations = Location::query()->paginate(20); $locations = Location::query()->paginate(20);
return redirect()->route("locations.index", ['locations' => $locations]); return redirect()->route("washing-machines.index", ['locations' => $locations]);//washing-machines.index kan byttes ud med locations.index
} }
} }
@ -114,13 +114,13 @@ class LocationController extends Controller
// If there already is a washing machine with that name, then don't change it // If there already is a washing machine with that name, then don't change it
if (count($allMachines) > 0) if (count($allMachines) > 0)
return redirect()->route("locations.index"); return redirect()->route("washing-machines.index");
else { // Else - Change the name else { // Else - Change the name
$location->update($data); $location->update($data);
$location->save(); $location->save();
$locations = Location::query()->paginate(20); $locations = Location::query()->paginate(20);
return redirect()->route("locations.index", ["locations" => $locations]); return redirect()->route("washing-machines.index", ["locations" => $locations]); //washing-machines.index kan byttes ud med locations.index
} }
} }
@ -148,7 +148,7 @@ class LocationController extends Controller
$location->delete(); $location->delete();
return redirect()->route("locations.index"); return redirect()->route("washing-machines.index");//washing-machines.index kan byttes ud med locations.index
} }
public function nameCheck(Request $request){ public function nameCheck(Request $request){

View File

@ -29,7 +29,7 @@ class RolesController extends Controller
*/ */
public function index(Request $request) public function index(Request $request)
{ {
$roles = Role::query()->where("id", "!=", 1)->paginate(20); $roles = Role::query()->where("id", "!=", 1)->where("id", "!=", 2)->paginate(20);
return Response::detect("roles.index", [ "roles" => $roles]); return Response::detect("roles.index", [ "roles" => $roles]);
} }
@ -104,7 +104,7 @@ class RolesController extends Controller
*/ */
public function edit($id) public function edit($id)
{ {
if($id == 1) if($id == 1 || $id == 2)
return redirect()->route("roles.index"); return redirect()->route("roles.index");
$role = Role::find($id); $role = Role::find($id);
@ -120,7 +120,7 @@ class RolesController extends Controller
*/ */
public function update(Request $request, $id) public function update(Request $request, $id)
{ {
if($id == 1) if($id == 1 || $id == 2)
return redirect()->route("roles.index"); return redirect()->route("roles.index");
$data = $request->validate([ $data = $request->validate([
@ -170,7 +170,7 @@ class RolesController extends Controller
*/ */
public function destroy($id) public function destroy($id)
{ {
if($id == 1) if($id == 1 || $id == 2)
return redirect()->route("roles.index"); return redirect()->route("roles.index");
$role = Role::find($id); $role = Role::find($id);
@ -187,7 +187,7 @@ class RolesController extends Controller
"<th style=\"width: 1em;\"><img class=\"w-100\" src=".asset('/images/icons/pencil.svg')." alt=\"Update\"></th>". "<th style=\"width: 1em;\"><img class=\"w-100\" src=".asset('/images/icons/pencil.svg')." alt=\"Update\"></th>".
"<th style=\"width: 1em;\"><img class=\"w-100\" src=".asset('/images/icons/trashcan.svg')." alt=\"Delete\"></th>". "<th style=\"width: 1em;\"><img class=\"w-100\" src=".asset('/images/icons/trashcan.svg')." alt=\"Delete\"></th>".
"</tr>"; "</tr>";
$roles = DB::table('roles')->where("id", "!=", 1)->where('name', 'LIKE',$request->search.'%')->get(); $roles = DB::table('roles')->where("id", "!=", 1)->where("id", "!=", 2)->where('name', 'LIKE',$request->search.'%')->get();
if(count($roles) !== 0){ if(count($roles) !== 0){
foreach ($roles as $key => $role){ foreach ($roles as $key => $role){

View File

@ -150,11 +150,6 @@
<div class="tooltip"><h3 class="text-white"><a href="{{ route('events.index') }}" class="text-white"><img src="{{asset("/images/icons/Aktiviteter.svg")}}" class="fa"><span style="margin-left: 4px;">Aktiviteter</span></a></h3><span class="tooltiptext">Aktiviteter</span></div> <div class="tooltip"><h3 class="text-white"><a href="{{ route('events.index') }}" class="text-white"><img src="{{asset("/images/icons/Aktiviteter.svg")}}" class="fa"><span style="margin-left: 4px;">Aktiviteter</span></a></h3><span class="tooltiptext">Aktiviteter</span></div>
</div> </div>
@endif @endif
@if(auth()->user()->can('locations.show'))
<div class="segment @if(\Illuminate\Support\Facades\Request::route()->getName() == "locations.index") active @endif">
<div class="tooltip"><h3 class="text-white"><a href="{{ route('locations.index') }}" class="text-white"><img src="{{asset("/images/icons/location.svg")}}" class="fa"><span style="margin-left: 4px;">Lokationer</span></a></h3><span class="tooltiptext">Lokationer</span></div>
</div>
@endif
@if(auth()->user()->can('washing.machine.show')) @if(auth()->user()->can('washing.machine.show'))
<div class="segment @if(\Illuminate\Support\Facades\Request::route()->getName() == "washing-machines.index") active @endif"> <div class="segment @if(\Illuminate\Support\Facades\Request::route()->getName() == "washing-machines.index") active @endif">
<div class="tooltip"><h3 class="text-white"><a href="{{ route('washing-machines.index') }}" class="text-white"><img src="{{asset("/images/icons/wash.svg")}}" class="fa"><span style="margin-left: 4px;">Vaskemaskiner</span></a></h3><span class="tooltiptext">Vaskemaskiner</span></div> <div class="tooltip"><h3 class="text-white"><a href="{{ route('washing-machines.index') }}" class="text-white"><img src="{{asset("/images/icons/wash.svg")}}" class="fa"><span style="margin-left: 4px;">Vaskemaskiner</span></a></h3><span class="tooltiptext">Vaskemaskiner</span></div>

View File

@ -14,6 +14,9 @@
@if(auth()->user()->can('washing.machine.create')) @if(auth()->user()->can('washing.machine.create'))
<a class="btn btn-inline btn-sde-blue mb-0" href="{{ route('washing-machines.create') }}"><img src="{{ asset('/images/icons/plus.svg') }}" alt="Create">Opret Vaskemaskine</a> <a class="btn btn-inline btn-sde-blue mb-0" href="{{ route('washing-machines.create') }}"><img src="{{ asset('/images/icons/plus.svg') }}" alt="Create">Opret Vaskemaskine</a>
@endif @endif
@if(auth()->user()->can('locations.create'))
<a class="btn btn-inline btn-sde-blue mb-0 ml-1" href="{{ route('locations.create') }}"><img src="{{ asset('/images/icons/plus.svg') }}" alt="Create">Opret Vaskemaskine lokation</a>
@endif
<div class="mt-1 ml-1"> <div class="mt-1 ml-1">
<select name="risRosName" id="locationID"> <select name="risRosName" id="locationID">
<option selected="selected" name="all" value="all">Alle</option> <option selected="selected" name="all" value="all">Alle</option>
@ -23,7 +26,9 @@
</select> <label>Vælg bygning</label> </select> <label>Vælg bygning</label>
</div> </div>
</div> </div>
<table class="tbl mt-2"> <div id="searchWashingMachine" class="mt-2">
<label>Vaskemaskiner</label>
<table id="washingSearch" class="tbl">
<tr> <tr>
<th>Navn</th> <th>Navn</th>
<th>Lokation</th> <th>Lokation</th>
@ -53,8 +58,43 @@
</tr> </tr>
@endforeach @endforeach
</table> </table>
</div>
<div id="locations" class="mt-2">
<label>Vaskemaskine lokation</label>
<table class="tbl">
<tr>
<th>Navn</th>
<th style="width: 1em;"><img class="w-100" src="{{ asset('/images/icons/eye.svg') }}" alt="Show"></th>
@if(auth()->user()->can('locations.edit'))
<th style="width: 1em;"><img class="w-100" src="{{ asset('/images/icons/pencil.svg') }}" alt="Update"></th>
@endif
@if(auth()->user()->can('locations.delete'))
<th style="width: 1em;"><img class="w-100" src="{{ asset('/images/icons/trashcan.svg') }}" alt="Delete"></th>
@endif
</tr>
@foreach(\App\Location::query()->get() as $location)
<tr>
<td>{{$location->name}}</td>
<td><a href="{{ route("locations.show", [ "location" => $location ]) }}"><img class="w-100" src="{{ asset('/images/icons/eye-dark.svg') }}" alt="Show"></a></td>
@if(auth()->user()->can('locations.edit'))
<td><a href="{{ route("locations.edit", [ "location" => $location ]) }}"><img class="w-100" src="{{ asset('/images/icons/pencil-dark.svg') }}" alt="Update"></a></td>
@endif
@if(auth()->user()->can('locations.delete'))
<td><form method="post" action="{{ route("locations.destroy", [ "location" => $location ]) }}" class="w-100 nostyle">
@csrf
@method("delete")
<button onclick="return confirm('Are you sure you want to delete?');" class="w-100 nostyle" type="submit"><img class="w-100 cursor-pointer" src="{{ asset('/images/icons/trashcan-dark.svg') }}" alt="Delete"></button>
</form>
</td>
@endif
</tr>
@endforeach
</table>
{{ $machines->links() }} {{ $machines->links() }}
</div>
<script> <script>
$('#locationID').change(function () { $('#locationID').change(function () {
@ -65,8 +105,7 @@
url: '{{route('washing-machines.search')}}', url: '{{route('washing-machines.search')}}',
data: {'option':$value}, data: {'option':$value},
success:function (data) { success:function (data) {
console.log($value); $('#washingSearch').html(data);
$('tbody').html(data);
}, },
error:function (data) { error:function (data) {
console.log(data); console.log(data);