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;
|
|
|
|
|
2021-10-23 01:06:30 +02:00
|
|
|
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;
|
2021-10-23 01:06:30 +02:00
|
|
|
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
|
|
|
{
|
2020-04-23 00:49:23 +02: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,
|
2022-06-21 11:57:17 +02:00
|
|
|
'key' => $invitation ? $invitation->key : false,
|
2022-08-24 10:28:08 +02:00
|
|
|
'invitation' => $invitation
|
2022-02-10 01:36:44 +01:00
|
|
|
];
|
2021-10-23 01:06:30 +02:00
|
|
|
|
2022-06-21 11:57:17 +02:00
|
|
|
if ($invitation && auth()->guard('contact') && ! request()->has('silent') && ! $invitation->viewed_date) {
|
|
|
|
$invitation->markViewed();
|
2021-10-23 01:06:30 +02:00
|
|
|
|
2022-06-21 11:57:17 +02:00
|
|
|
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
|
|
|
}
|
|
|
|
}
|