<?php
namespace CamilStaps\BotleaguesApi\Controllers;

use CamilStaps\BotleaguesApi\Database\Participant;
use Illuminate\Support\Facades\Input;

class ParticipantController extends BaseController {

    protected $participant;

    public function __construct(Participant $participant) {
        $this->participant = $participant;
    }

    public function index() {
        return $this->participant->all();
    }
    
    public function show($id) {
        return $this->participant->findOrFail($id);
    }

    public function update($id) {
        throw new \Exception("Not implemented yet.");
    }

    public function store() {
        $this->participant->fill(Input::all());

        if ($this->participant->save()) {
            return $this->response->created();
        } else {
            throw new \Dingo\Api\Exception\StoreResourceFailedException;
        }
    }

}