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

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