2020-03-23 18:10:42 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
$data = ['credit' => $credit];
|
|
|
|
|
2021-10-23 01:06:30 +02:00
|
|
|
$invitation = $credit->invitations()->where('client_contact_id', auth()->user()->id)->first();
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|