<?php

namespace App\Modules\Bookings;

use Illuminate\Support\Facades\View;
use Illuminate\Support\Facades\Redirect;
use App\Models\Status;

class RmaController extends AbstractPageController
{
    /**
     *	Returns the index page.
     */
    public function getIndex($id = 0)
    {
        if (! $id) {
            return Redirect::to('/');
        }

        $rma = Rma::find($id);

        // Redirect back to the dashboard if the ID was not
        // found or the task is not a remote rma one.
        if (! $rma or $rma->type != 'rma') {
            return Redirect::to('/');
        }

        $this->loadData();
        $this->data['statuses'] = Status::rma()->get();
        $this->data['task'] = $rma;

        $this->layout->content = View::make('bookings::rma.index', $this->data);
    }
}
