HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/vebon.komma.pro/app/KommaApp/Members/MemberController.php
<?php

namespace KommaApp\Members;

use KommaApp\Audit\AuditService;
use KommaApp\Audit\Models\Audit;
use KommaApp\Core\CoreController;
use KommaApp\EndUsers\Models\EndUser;

/**
 * Short description for the file.
 *
 * @author      Tim Van Samang <timvansamang@komma.pro>
 * @copyright   (c) 2012-2015, Komma Mediadesign
 */
class MemberController extends CoreController
{
    private $endUser;
    /**
     * @var AuditService
     */
    private $auditService;

    /**
     * MemberController constructor.
     * @param AuditService $auditService
     */
    public function __construct(AuditService $auditService)
    {
        $this->middleware('auth:endUser');
        $this->endUser = \Auth::endUser()->get();
        $this->auditService = $auditService;
    }

    /**
     * Show the archive of audits for the logged in member
     *
     * @param EndUser $member
     * @return mixed
     */
    public function archive(EndUser $member)
    {
        //Check if the member is the same as the Logged in users, if not trow 403
        if ($member != $this->endUser) return \App::abort(403);

        //Get the audits closed audtis, and sort these by descending year
        $audits = $this->auditService->getEndUserClosedAudits($member)->sortByDesc('year');


        return \View::make('members.archive')->with(['audits' => $audits]);

    }

}