title: Laravel Abstract Class Repository
body: <p>Hi I'm trying to implement the repository pattern in laravel with abstract class to have some base functions which is I'm new at.</p>
  
  <p>I'm getting </p>
  
  <blockquote>
    <p>Parse error:syntax error, unexpected '->' (T_OBJECT_OPERATOR)</p>
  </blockquote>
  
  <p>on the line AbstractRepository->create($request);
  when I call the function from the abstract in the repository. Here are the codes</p>
  
  <p>AbstractRepository.php</p>
  
  <pre><code>    &lt;?php
  
      namespace App\Abstracts;
  
      use App\Exceptions\NoResourceFoundException;
      use App\Exceptions\ResourceNotFoundException;
  
      abstract class AbstractRepository
      {
  
          /**
           * @var Model
           */
          protected $model;
  
          /**
           * @var array
           */
          public $errors = [];
  
          /**
           * @param Model $model
           */
          public function __construct(Model $model)
          {
              $this-&gt;model = $model;
          }
  
          public function create(array $data)
          {
              return $this-&gt;model-&gt;create($data);
          }
     }
  </code></pre>
  
  <p>ReportRepositoryInterface.php</p>
  
  <pre><code>&lt;?php
  
  namespace App\Interfaces;
  
  interface ReportRepositoryInterface {
  
    public function createReport (array $data);
  }
  ?&gt;
  </code></pre>
  
  <p>ReportRepository.php</p>
  
  <pre><code>&lt;?php
  
  namespace App\Repositories;
  
  use App\Interfaces\ReportRepositoryInterface;
  use App\Models\Report;
  use App\Services\ApiResponse;
  use Illuminate\Http\Request;
  use App\Abstracts\AbstractRepository;
  
  class ReportRepository implements ReportRepositoryInterface {
  
    public function createReport(array $request){
      AbstractRepository-&gt;create($request);
      return ApiResponse::responseData($request, 'Record successfully created!');
    }
  }
  
  ?&gt;
  </code></pre>
  
  <p>ReportsController.php</p>
  
  <pre><code>&lt;?php
  
  namespace App\Http\Controllers;
  
  use Illuminate\Http\Request;
  use App\Interfaces\ReportRepositoryInterface;
  use Illuminate\Support\Facades\Log;
  
  class ReportsController extends Controller
  {
  
    public function __construct(ReportRepositoryInterface $report, Request $request)
    {
      $this-&gt;report = $report;
      $this-&gt;request = $request;
    }
  
    public function createReport()
    {
      $data = $this-&gt;request-&gt;all();
          return $this-&gt;report-&gt;createReport($data);
    }
  }
  </code></pre>
  
  <p>Can anyone enlighten me? Thank you</p>