@php
$addDocumentPermission = user()->permission('add_documents');
$viewDocumentPermission = user()->permission('view_documents');
$deleteDocumentPermission = user()->permission('delete_documents');
$editDocumentPermission = user()->permission('edit_documents');
@endphp
@if ($addDocumentPermission == 'all')
@endif
@php
$totalDocuments = ($user->documents) ? count($user->documents) : 0;
$permission = 0; // assuming we do have permission for all uploaded files
@endphp
@forelse($user->documents as $file)
@if ($viewDocumentPermission == 'all'
|| ($viewDocumentPermission == 'added' && $file->added_by == user()->id)
|| ($viewDocumentPermission == 'owned' && ($file->user_id == user()->id && $file->added_by != user()->id))
|| ($viewDocumentPermission == 'both' && ($file->added_by == user()->id || $file->user_id == user()->id)))
@if ($file->icon == 'images')
@else
@endif
@if ($viewDocumentPermission == 'all'
|| ($viewDocumentPermission == 'added' && $file->added_by == user()->id)
|| ($viewDocumentPermission == 'owned' && ($file->user_id == user()->id && $file->added_by != user()->id))
|| ($viewDocumentPermission == 'both' && ($file->added_by == user()->id || $file->user_id == user()->id)))
@lang('app.view')
@lang('app.download')
@endif
@if ($editDocumentPermission == 'all'
|| ($editDocumentPermission == 'added' && $file->added_by == user()->id)
|| ($editDocumentPermission == 'owned' && ($file->user_id == user()->id && $file->added_by != user()->id))
|| ($editDocumentPermission == 'both' && ($file->added_by == user()->id || $file->user_id == user()->id)))
@lang('app.edit')
@endif
@if ($deleteDocumentPermission == 'all'
|| ($deleteDocumentPermission == 'added' && $file->added_by == user()->id)
|| ($deleteDocumentPermission == 'owned' && ($file->user_id == user()->id && $file->added_by != user()->id))
|| ($deleteDocumentPermission == 'both' && ($file->added_by == user()->id || $file->user_id == user()->id)))
@lang('app.delete')
@endif
@else
@php
$permission++;
@endphp
@endif
@empty
- @lang('messages.noFileUploaded')
@endforelse
@if (isset($user->clientDocuments) && $totalDocuments > 0 && $totalDocuments == $permission)
- @lang('messages.noFileUploaded') -
@endif