1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 21:22:58 +01:00
invoiceninja/app/Http/Controllers/ClientPortal/CreditController.php

56 lines
1.8 KiB
PHP
Raw Normal View History

2020-03-23 18:10:42 +01:00
<?php
2022-01-06 00:19:31 +01:00
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
2023-01-28 23:21:40 +01:00
* @copyright Copyright (c) 2023. Invoice Ninja LLC (https://invoiceninja.com)
2022-01-06 00:19:31 +01:00
*
* @license https://www.elastic.co/licensing/elastic-license
*/
2020-03-23 18:10:42 +01:00
namespace App\Http\Controllers\ClientPortal;
use App\Events\Credit\CreditWasViewed;
use App\Events\Misc\InvitationWasViewed;
2020-03-23 18:10:42 +01:00
use App\Http\Controllers\Controller;
2021-06-17 14:28:46 +02:00
use App\Http\Requests\ClientPortal\Credits\ShowCreditRequest;
use App\Http\Requests\ClientPortal\Credits\ShowCreditsRequest;
2020-03-23 18:10:42 +01:00
use App\Models\Credit;
use App\Utils\Ninja;
2020-03-23 18:10:42 +01:00
class CreditController extends Controller
{
2021-06-17 14:28:46 +02:00
public function index(ShowCreditsRequest $request)
2020-03-23 18:10:42 +01:00
{
return $this->render('credits.index');
2020-03-23 18:10:42 +01:00
}
public function show(ShowCreditRequest $request, Credit $credit)
{
2021-05-18 12:03:06 +02:00
set_time_limit(0);
2023-08-17 02:57:25 +02:00
// $invitation = $credit->invitations()->where('client_contact_id', auth()->user()->id)->first();
$invitation = $credit->invitations()->where('client_contact_id', auth()->guard('contact')->user()->id)->first();
2021-05-18 12:03:06 +02:00
2022-02-10 01:36:44 +01:00
$data = [
'credit' => $credit,
'key' => $invitation ? $invitation->key : false,
'invitation' => $invitation
2022-02-10 01:36:44 +01:00
];
if ($invitation && auth()->guard('contact') && ! request()->has('silent') && ! $invitation->viewed_date) {
$invitation->markViewed();
event(new InvitationWasViewed($credit, $invitation, $credit->company, Ninja::eventVars()));
event(new CreditWasViewed($invitation, $invitation->company, Ninja::eventVars()));
}
2021-05-18 12:03:06 +02:00
if ($request->query('mode') === 'fullscreen') {
return render('credits.show-fullscreen', $data);
}
return $this->render('credits.show', $data);
2020-03-23 18:10:42 +01:00
}
}