Fixes for viewing soft deleted invites

This commit is contained in:
David Bomba 2022-06-17 09:08:07 +10:00
parent e4ba8e16a7
commit e546d7348a
3 changed files with 11 additions and 5 deletions

View File

@ -80,7 +80,8 @@ class InvitationController extends Controller
$entity_obj = 'App\Models\\'.ucfirst(Str::camel($entity)).'Invitation';
$invitation = $entity_obj::where('key', $invitation_key)
$invitation = $entity_obj::withTrashed()
->where('key', $invitation_key)
->whereHas($entity, function ($query) {
$query->where('is_deleted',0);
})
@ -186,7 +187,8 @@ class InvitationController extends Controller
$entity_obj = 'App\Models\\'.ucfirst(Str::camel($entity)).'Invitation';
$invitation = $entity_obj::where('key', $invitation_key)
$invitation = $entity_obj::withTrashed()
->where('key', $invitation_key)
->with('contact.client')
->firstOrFail();
@ -228,7 +230,8 @@ class InvitationController extends Controller
public function payInvoice(Request $request, string $invitation_key)
{
$invitation = InvoiceInvitation::where('key', $invitation_key)
$invitation = InvoiceInvitation::withTrashed()
->where('key', $invitation_key)
->with('contact.client')
->firstOrFail();

View File

@ -46,7 +46,8 @@ class InvitationController extends Controller
Auth::logout();
$invitation = PurchaseOrderInvitation::where('key', $invitation_key)
$invitation = PurchaseOrderInvitation::withTrashed()
->where('key', $invitation_key)
->whereHas('purchase_order', function ($query) {
$query->where('is_deleted',0);
})

View File

@ -141,6 +141,8 @@ class PurchaseOrderController extends Controller
->whereIn('id', $this->transformKeys($data['purchase_orders']))
->where('company_id', auth()->guard('vendor')->user()->vendor->company_id)
->whereIn('status_id', [PurchaseOrder::STATUS_DRAFT, PurchaseOrder::STATUS_SENT])
->where('is_deleted', 0)
->withTrashed()
->cursor()->each(function ($purchase_order){
$purchase_order->service()
@ -159,7 +161,7 @@ class PurchaseOrderController extends Controller
if(count($data['purchase_orders']) == 1){
$purchase_order = PurchaseOrder::whereIn('id', $this->transformKeys($data['purchase_orders']))->first();
$purchase_order = PurchaseOrder::withTrashed()->where('is_deleted', 0)->whereIn('id', $this->transformKeys($data['purchase_orders']))->first();
return redirect()->route('vendor.purchase_order.show', ['purchase_order' => $purchase_order->hashed_id]);