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

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