<?php namespace App\Modules\Backend\Articles\Controllers;

use Auth, Input, Redirect, View, DB, Datatables, Validator, Innfile, Hash, Alert, Acl, Dashboard;
use App\Modules\Frontend\Principal\Models\Record;

class RecordsController extends \BaseController {

	/**
	 * Constructor
	 */
	public function __construct() {
        View::share('active_module', 'records');
    }


    /**
	 * Ejecutado cuando acceden a /admin/users
	 * @return string Muestra la pantalla con todos los usuarios registrados en el sistema.
	 */
	public function getIndex()
	{
		Acl::canOrFail('records', 'view');
		return View::make('articles::index_records');
	}


	/**
	 * Genera el Json con todos los articulos.
	 * @return string Json con datos para datatables
	 */
	public function getTablaAjax()
	{
		Acl::canOrFail('records', 'view');
		$datas 		= Record::select('captain_name', 'created_at', 'id');
		//$options 	= ;
		return Datatables::of($datas)
				->edit_column('captain_name', 		'{{ $captain_name }} <input type="hidden" class="id" value="{{ $id }}" >')
				->make();
	}

	public function show($id)
	{
		Acl::canOrFail('records', 'view');
		$record = Record::findOrFail($id);
		$jackpots = json_decode($record->optional_jackpots);
		$anglers = json_decode($record->others_anglers);

		return View::make('articles::show', compact('record', 'jackpots', 'anglers'));

	}

}