Add $user (authed user) to views

This commit is contained in:
Deon George
2021-09-28 00:21:21 +10:00
parent ca666e456a
commit 2c406ba3e9
7 changed files with 59 additions and 8 deletions

View File

@@ -150,7 +150,7 @@
@guest
To start an application to join this network please <a href="{{ url('login') }}">login</a>.
@else
@if(Auth::user()->isMember($o))
@if($user->isMember($o))
@else
This website is not ready to take applications yet, check back soon!
@endif

View File

@@ -27,7 +27,7 @@
<dl>
<dt>Expore Networks</dt>
@foreach (\App\Models\Domain::active()
->when(! \Illuminate\Support\Facades\Auth::check(),function($query) { return $query->public(); })
->when((! $user),function($query) { return $query->public(); })
->orderBy('name')->get() as $o)
<dd><a href="{{ url('network',['id'=>$o->id]) }}" title="{{ $o->description }}">{{ $o->name }}</a></dd>
@endforeach

View File

@@ -15,8 +15,8 @@
<ul class="float-end">
@auth
<li class="{{ Auth::user()->switched ? 'switched' : '' }}"><a href="{{ url('settings') }}"><span>{{ Auth::user()->name }}</span></a></li>
@if(Auth::user()->switched)
<li class="{{ $user->switched ? 'switched' : '' }}"><a href="{{ url('settings') }}"><span>{{ $user->name }}</span></a></li>
@if($user->switched)
<li><a href="{{ url('admin/switch/stop') }}">
<span>Switch Back</span>
</a></li>

View File

@@ -62,11 +62,11 @@
<div class="col-4">
<label for="admin" class="form-label">Site Admin</label>
<div class="input-group">
<div class="btn-group" role="group" @if($o->id == Auth::user()->id)data-bs-toggle="tooltip" title="You cannot demote yourself" @endif>
<div class="btn-group" role="group" @if($user->id == $o->id)data-bs-toggle="tooltip" title="You cannot demote yourself" @endif>
<input type="radio" class="btn-check" name="admin" id="admin_yes" value="1" required @cannot('admin',$o)disabled @endcannot @if(old('admin',$o->admin))checked @endif>
<label class="btn btn-outline-success" for="admin_yes">Yes</label>
<input type="radio" class="btn-check btn-danger" name="admin" id="admin_no" value="0" required @if($o->id == Auth::user()->id || Auth::user()->cannot('admin',$o)) disabled @endif @if(! old('admin',$o->admin))checked @endif>
<input type="radio" class="btn-check btn-danger" name="admin" id="admin_no" value="0" required @if(($user->id == $o->id) || $user->cannot('admin',$o)) disabled @endif @if(! old('admin',$o->admin))checked @endif>
<label class="btn btn-outline-danger" for="admin_no">No</label>
</div>
</div>
@@ -100,7 +100,7 @@
@endsection
@section('page-scripts')
@if($o->id == Auth::user()->id)
@if($user->id == $o->id)
<script>
var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'))
var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) {

View File

@@ -28,7 +28,7 @@
<tbody>
@foreach (\App\Models\User::orderBy('email')->cursor() as $oo)
<tr class="{{ $oo->admin ? 'admin' : '' }}">
<td><a href="{{ url('user/addedit',[$oo->id]) }}">{{ $oo->id }}</a> @if(Auth::user()->admin && (Auth::id() !== $oo->id))<span class="float-end"><a href="{{ url('admin/switch/start',[$oo->id]) }}"><i class="bi bi-person-bounding-box"></i></a></span>@endif</td>
<td><a href="{{ url('user/addedit',[$oo->id]) }}">{{ $oo->id }}</a> @if($user->admin && ($user->id !== $oo->id))<span class="float-end"><a href="{{ url('admin/switch/start',[$oo->id]) }}"><i class="bi bi-person-bounding-box"></i></a></span>@endif</td>
<td>{{ $oo->email }}</td>
<td>{{ $oo->name }}</td>
<td>{{ $oo->active ? 'YES' : 'NO' }}</td>