<?php
namespace App\Http\Controllers\Painel;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Repository\Painel\DeptoproRepository;

class DeptoproController extends Controller
{
  public  $uri;
  public function __construct(DeptoproRepository $DeptoproRepository, Request $req){
    $this->DeptoproRepository = $DeptoproRepository;
    $uri = $req->route()->uri();
    $uri = explode('/', $uri);
        if (count($uri) > 1){
      if($uri[1] == 'search'){
        $this->uri = 'Departamentos';
      }else {
        $this->uri = ucfirst($uri[1]);
      }
    }else{
      $this->uri = '';
    }
  }
  public function show(){
    return $this->DeptoproRepository->show($this->uri);
  }
  public function search(Request $req){
    return $this->DeptoproRepository->search($req,$this->uri);
  }
  public function add(){
    return $this->DeptoproRepository->add($this->uri);
  }
  public function edit($id){
    return $this->DeptoproRepository->edit($id, $this->uri);
  }
  public function save(Request $req){
    return $this->DeptoproRepository->save($req);
  }
  public function delete($id){
    return $this->DeptoproRepository->delete($id);
  }
}
