撰寫 Laravel PHP 代碼以賦予 hr 查看特定列的角色是正確的方法嗎?因為托管后網站會自動停止并自動啟動。代碼作業正常..
我是 PHP 的新手,我不知道我在這段代碼中是否出錯了,誰能幫我解決一下...
<table class="table table-striped mb-0 dataTable">
<thead>
<tr>
@role('company')
<th>{{__('Employee Name')}}</th>
@endrole
@role('hr')
<th>{{__('Employee Name')}}</th>
@endrole
<th>{{__('Designation')}}</th>
<th>{{__('Promotion Title')}}</th>
<th>{{__('Promotion Date')}}</th>
<th>{{__('Description')}}</th>
@if(Gate::check('Edit Promotion') || Gate::check('Delete Promotion'))
<th width="200px">{{__('Action')}}</th>
@endif
</tr>
</thead>
<tbody class="font-style">
@foreach ($promotions as $promotion)
<tr>
@role('company')
<td>{{ !empty($promotion->employee())?$promotion->employee()->name:'' }}</td>
@endrole
@role('hr')
<td>{{ !empty($promotion->employee())?$promotion->employee()->name:'' }}</td>
@endrole
<td>{{ !empty($promotion->designation())?$promotion->designation()->name:'' }}</td>
<td>{{ $promotion->promotion_title }}</td>
<td>{{ \Auth::user()->dateFormat($promotion->promotion_date) }}</td>
<td>{{ $promotion->description }}</td>
@if(Gate::check('Edit Promotion') || Gate::check('Delete Promotion'))
<td>
@can('Edit Promotion')
<a href="#" data-url="{{ URL::to('promotion/'.$promotion->id.'/edit') }}" data-size="lg" data-ajax-popup="true" data-title="{{__('Edit Promotion')}}" class="edit-icon" data-toggle="tooltip" data-original-title="{{__('Edit')}}"><i hljs-string">"></i></a>
@endcan
@can('Delete Promotion')
<a href="#" data-toggle="tooltip" data-original-title="{{__('Delete')}}" data-confirm="{{__('Are You Sure?').'|'.__('This action can not be undone. Do you want to continue?')}}" data-confirm-yes="document.getElementById('delete-form-{{$promotion->id}}').submit();"><i ></i></a>
{!! Form::open(['method' => 'DELETE', 'route' => ['promotion.destroy', $promotion->id],'id'=>'delete-form-'.$promotion->id]) !!}
{!! Form::close() !!}
@endif
</td>
@endif
</tr>
@endforeach
</tbody>
</table>
uj5u.com熱心網友回復:
您可以在此處的檔案中找到您要問的內容(左側選擇版本):https :
//spatie.be/docs/laravel-permission/v5/basic-usage/blade-directives
@role('hr')
I am from hr!
@else
I am not from hr...
@endrole
它進一步讀取的@hasrole('hr')是 的別名@role('hr'),所以不用擔心。
同樣,權限也是如此:
@can('edit articles')
//
@endcan
有關更多資訊,請參閱上面提到的鏈接。
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/380508.html
