Replace 404 with not available screen for deleted entities

This commit is contained in:
= 2022-07-25 10:47:18 +10:00
parent 375b663425
commit 80ad607e62
4 changed files with 39 additions and 5 deletions

View File

@ -81,15 +81,16 @@ class InvitationController extends Controller
$entity_obj = 'App\Models\\'.ucfirst(Str::camel($entity)).'Invitation';
$invitation = $entity_obj::withTrashed()
->with($entity)
->where('key', $invitation_key)
->whereHas($entity, function ($query) {
$query->where('is_deleted',0);
})
// ->whereHas($entity, function ($query) {
// $query->where('is_deleted',0);
// })
->with('contact.client')
->first();
if(!$invitation)
return abort(404,'The resource is no longer available.');
if($invitation->{$entity}->is_deleted)
return $this->render('generic.not_available', ['account' => $invitation->company->account, 'company' => $invitation->company]);
/* 12/01/2022 Clean up an edge case where if the contact is trashed, restore if a invitation comes back. */
if($invitation->contact->trashed())

View File

@ -13,6 +13,7 @@ namespace App\Models\Presenters;
use App\Models\Country;
use Illuminate\Support\Str;
use Illuminate\Support\Facades\Storage;
/**
* Class CompanyPresenter.

View File

@ -4729,6 +4729,7 @@ $LANG = array(
'converted_to_expense' => 'Successfully converted to expense',
'converted_to_expenses' => 'Successfully converted to expenses',
'entity_removed' => 'This document has been removed, please contact the vendor for further information',
'entity_removed_title' => 'Document no longer available',
);
return $LANG;

View File

@ -0,0 +1,31 @@
@extends('portal.ninja2020.layout.clean')
@section('meta_title', ctrans('texts.error'))
@section('body')
<div class="flex h-screen">
<div class="m-auto md:w-1/2 lg:w-1/2">
<div class="flex flex-col items-center">
@if($account && !$account->isPaid())
<div>
<img src="{{ asset('images/invoiceninja-black-logo-2.png') }}"
class="border-b border-gray-100 h-18 pb-4" alt="Invoice Ninja logo">
</div>
@elseif(isset($company) && !is_null($company))
<div>
<img src="{{ $company->present()->logo() }}"
class="mx-auto border-b border-gray-100 h-18 pb-4" alt="{{ $company->present()->name() }} logo">
</div>
@endif
<h1 class="text-center text-3xl mt-10">{{ ctrans("texts.entity_removed_title") }}</h1>
<p class="text-center opacity-75 mt-10">{{ ctrans('texts.entity_removed') }}</p>
</div>
</div>
</div>
@stop
@push('footer')
@endpush