Personal I have a simple class with 2 methods, here is the code:
namespace app\Services;
use App\Repositories\LogRepository;
class LogService
{
protected $repository;
public function __construct(LogRepository $repository){
$this->repository=$repository;
}
public function cadastrar($dados){
return 'ola2';
}
public function deletar($id=0)
{
return 'ola';
}
}
And in another class I call this class:
namespace app\Classes;
use App\Repositories\LogRepository;
use app\Services\LogService;
class Log
{
private static $repository;
private static $service;
public function __construct(LogRepository $repository, LogService $service)
{
self::$repository=$repository;
self::$service=$service;
}
static function Gravar($tabela, $evento, $sql=null, $valoresAntigos, $valoresNovos){
self::$service->deletar(1);
return true;
}
}
When I run it gives me the following error:
FatalErrorException in Log.php line 29: Call a member function delete () on null
What am I forgetting to do or doing wrong? Thanks