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

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