<?php

namespace App\Modules\Bookings;

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

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

        $sale_lead = SaleLead::find($id);

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

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

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