Home > Net >  Symfony \ Component \ ErrorHandler \ Error \ FatalError - Could not check compatibility
Symfony \ Component \ ErrorHandler \ Error \ FatalError - Could not check compatibility

Time:01-16

I have followed the steps for creating tables in Laravel from enter image description here

app/Http/Livewire/UsersTable.php

<?php

namespace App\Http\Livewire;

use Livewire\Component;

class UsersTable extends Table
{
    public function query() : Builder
    {
        return User::query();
    }
    
    public function columns() : array
    {
      return [
           Column::make('name', 'Name'),
           Column::make('email', 'Email'),
           Column::make('status', 'Status'),
           Column::make('created_at', 'Created At'),
       ];
    }
}

app/Http/Livewire/Table.php

<?php

namespace App\Http\Livewire;

use Livewire\Component;

abstract class Table extends Component
{
    public function render()
    {
        return view('livewire.table');
    }
    
    public abstract function query() : \Illuminate\Database\Eloquent\Builder;

    public abstract function columns() : array;

    public function data()
    {
      return $this
        ->query()
        ->get();
    }
}

What does this mean? What can I do?

CodePudding user response:

It just means that the model is not sure which Builder you want to use as a type of query, in your case its Illuminate\Database\Eloquent\Builder

So you can just reference it at the top of the class like this:

<?php

namespace App\Http\Livewire;

use Livewire\Component;
use Illuminate\Database\Eloquent\Builder;

class UsersTable extends Table
{
    public function query() : Builder
    {
        return User::query();
    }
    
    public function columns() : array
    {
      return [
           Column::make('name', 'Name'),
           Column::make('email', 'Email'),
           Column::make('status', 'Status'),
           Column::make('created_at', 'Created At'),
       ];
    }
}
  • Related