Bom dia Pessoal
Estou com seguinte erro quando testo pelo Insonomia , a minha API.
{
"error": "vtech\\di\\exceptions\\NotInstantiableException: Não foi possivel instanciar a classe app\\service\\ApuracaoHorasService. in \/home\/consultoriavtech\/public_html\/vtech-api\/vtech\/di\/Container.php:303\nStack trace:\n#0 \/home\/consultoriavtech\/public_html\/vtech-api\/vtech\/di\/Container.php(171): vtech\\di\\Container->getDependencies('app\\\\controller\\\\...')\n#1 \/home\/consultoriavtech\/public_html\/vtech-api\/vtech\/di\/Container.php(86): vtech\\di\\Container->build('app\\\\controller\\\\...', Array, Array)\n#2 \/home\/consultoriavtech\/public_html\/vtech-api\/vtech\/http\/Dispatcher.php(148): vtech\\di\\Container->get('app\\\\controller\\\\...')\n#3 \/home\/consultoriavtech\/public_html\/vtech-api\/vtech\/http\/Dispatcher.php(87): vtech\\http\\Dispatcher->getParamsAction()\n#4 \/home\/consultoriavtech\/public_html\/vtech-api\/vtech\/http\/Dispatcher.php(38): vtech\\http\\Dispatcher->setParams('GET')\n#5 \/home\/consultoriavtech\/public_html\/vtech-api\/vtech\/http\/Router.php(123): vtech\\http\\Dispatcher->__construct(Object(vtech\\http\\Route), Object(vtech\\http\\Request))\n#6 \/home\/consultoriavtech\/public_html\/vtech-api\/vtech\/http\/Router.php(36): vtech\\http\\Router->dispatch(Object(vtech\\http\\Route), Object(vtech\\http\\Request))\n#7 \/home\/consultoriavtech\/public_html\/vtech-api\/app\/core\/App.php(221): vtech\\http\\Router->__construct(Object(vtech\\http\\Request))\n#8 \/home\/consultoriavtech\/public_html\/vtech-api\/public\/index.php(24): app\\core\\App->run()\n#9 {main}"}
Já olhei a Class Service, esta assim, Podem me ajudar.
<?php
namespace app\service;
use app\model\ApuracaoHoras;
use app\repository\interfaces\ApuracaoHorasRepositoryInterface;
use app\Service\interfaces\ApuracaoHorasServiceInterface;
class ApuracaoHorasService implements ApuracaoHorasServiceInterface
{
/** @var ApuracaoHorasRepositoryInterface $apuracaohorasRepository */
private $apuracaohorasRepository;
public function __construct(ApuracaoHorasRepositoryInterface $apuracaohorasRepository)
{
$this->apuracaohorasRepository = $apuracaohorasRepository;
}
public function manter(ApuracaoHoras $apuracaohorasRepository, bool $excluir)
{
return $this->apuracaohorasRepository->manter($apuracaohorasRepository, $excluir);
}
public function consultarTodos($page, $totalItems)
{
return $this->apuracaohorasRepository->consultarTodos();
}
public function consultar()
{
return $this->apuracaohorasRepository->consultarTodos();
}
public function consultarPorId($id)
{
return $this->apuracaohorasRepository->consultarPorId($id);
}
}
Model
<?php
namespace app\model;
use JsonSerializable;
class ApuracaoHoras implements JsonSerializable
{
/** @var int|null $id */
private $id;
/** @var Empresa|null $empresa */
private $empresa;
/** @var Tarefas $tarefas */
private $tarefas;
/** @var Funcionario|null $funcionario */
private $funcionario;
/** @var \DateTime|null $date */
private $date;
/** @var double|null $qtdhoras */
private $qtdhoras;
/** @var Contratos|null $idcontrato */
private $idcontrato;
/**
* Get the value of id.
*
* @return int|null
*/
public function getId()
{
return $this->id;
}
/**
* Set the value of id.
*
* @param int|null $id
*
* @return self
*/
public function setId($id)
{
$this->id = $id;
return $this;
}
/**
* Get the value of empresa.
*
* @return Empresa
*/
public function getempresa()
{
return $this->empresa;
}
/**
* Set the value of empresa.
*
* @param Empresa $empresa
*
* @return self
*/
public function setempresa($empresa)
{
$this->empresa = $empresa;
return $this;
}
/**
* Get the value of tarefas.
*
* @return Tarefas
*/
public function gettarefas()
{
return $this->tarefas;
}
/**
* Set the value of tarefas.
*
* @param Tarefas $tarefas
*
* @return self
*/
public function settarefas($tarefas)
{
$this->tarefas = $tarefas;
return $this;
}
/**
* Get the value of funcionario.
*
* @return Funcionario
*/
public function getfuncionario()
{
return $this->funcionario;
}
/**
* Set the value of funcionario.
*
* @param Funcionario $funcionario
*
* @return self
*/
public function setfuncionario($funcionario)
{
$this->funcionario = $funcionario;
return $this;
}
/**
* Get the value of data.
*
* @return \DateTime|null
*/
public function getData()
{
return $this->data;
}
/**
* Set the value of data.
*
* @param \DateTime|null $data
*
* @return self
*/
public function setData($data)
{
$this->data = $data;
return $this;
}
/**
* Get the value of qtdhoras.
*
* @return double|null
*/
public function getQtdhoras()
{
return $this->qtdhoras;
}
/**
* Set the value of qtdhoras.
*
* @param double|null $qtdhoras
*
* @return self
*/
public function setQtdhoras($qtdhoras)
{
$this->qtdhoras = $qtdhoras;
return $this;
}
/**
* Get the value of idcontrato.
*
* @return Contrato
*/
public function getIdcontrato()
{
return $this->idcontrato;
}
/**
* Set the value of idcontrato.
*
* @param Contrato $idcontrato
*
* @return self
*/
public function setIdcontrato($idcontrato)
{
$this->idcontrato = $idcontrato;
return $this;
}
public function jsonSerialize()
{
return (object) get_object_vars($this);
}
/**
* Get the value of date.
*
* @return \DataTime
*/
public function getDate()
{
return $this->date;
}
/**
* Set the value of date.
*
* @param \Datetime|null $date
*
* @return self
*/
public function setDate($date) : self
{
$this->date = $date;
return $this;
}
}
Repositorio
<?php
namespace app\repository\interfaces;
use app\model\ApuracaoHoras;
interface ApuracaoHorasRepositoryInterface
{
public function manter(ApuracaoHoras $apuracaohoras, bool $excluir);
/**
* Consultar todos as ApuracaoHoras.
*
* @param int|null $page Número da página
* @param int|null $totalItems Número total de itens por página
* @return array
* @throws \Exception
**/
public function consultarTodos(int $page, int $totalItems, int $idempresa, $idcontrato, $idtarefa);
public function consultarPorId($id);
}