<?php
/**
 * app/plugins/members/controllers/admin/members/records.php
 *
 * This is the Membership Records admin controller.
 *
 * @package TP Members
 * @version 3.0
 * @author  Joey Kimsey <Joey@thetempusproject.com>
 * @link    https://TheTempusProject.com
 * @license https://opensource.org/licenses/MIT [MIT LICENSE]
 */
namespace TheTempusProject\Controllers\Admin;

use TheTempusProject\Houdini\Classes\Views;
use TheTempusProject\Houdini\Classes\Navigation;
use TheTempusProject\Houdini\Classes\Components;
use TheTempusProject\Classes\AdminController;
use TheTempusProject\Models\Memberships as MemberModel;

class Records extends AdminController {
    public static $memberships;

    public function __construct() {
        parent::__construct();
        self::$title = 'Admin - Memberships';
        self::$memberships = new MemberModel;
        $view = Navigation::activePageSelect( 'nav.admin', '/admin/member' );
        Components::set( 'ADMINNAV', $view );
    }

    public function index( $data = null ) {
        Views::view( 'members.admin.memberships.list', self::$memberships->list() );
    }

    public function create( $data = null ) {
    }

    public function edit( $data = null ) {
    }

    public function view( $id = null ) {
        $data = self::$memberships->findById( $id );
        if ( $data !== false ) {
            return Views::view( 'members.admin.memberships.view', $data );
        }
        Issues::add( 'error', 'Membership not found.' );
        $this->index();
    }

    public function delete( $data = null ) {
    }

    public function preview( $data = null ) {
    }
}
