2 years ago

#46537

test-img

Daniel R.

BlueFeatherGroup eloquent-filemaker connection problem

I'm using https://github.com/BlueFeatherGroup/eloquent-filemaker in a Laravel Project to get data from a FileMaker database.

I use a MySQL as default connection in my project, but I need a second connection to a FileMaker Server. I created in database.php config file a new conn:

    'filemaker' => [
        'driver' => 'filemaker',
        'host' => 'myfmhost',
        'database' => 'FMdatabase',
        'username' => 'FMUser',
        'password' => 'MFPass',
        'prefix' =>  '',
        'version' => 'vLatest',
        'protocol' => 'https',
    ],

I created a model "tabla" as follows:

use BlueFeather\EloquentFileMaker\Database\Eloquent\FMModel;

use Illuminate\Database\Eloquent\Factories\HasFactory;


class tabla extends FMModel
{
    use HasFactory;

    protected $connection= 'filemaker';
    protected $fillable = [ ];
    protected $layout = 'tabla';

}

In my Controller:

$data = tabla::all();
dd($data);

and I get this error:

Argument 1 passed to BlueFeather\EloquentFileMaker\Database\Query\FMBaseBuilder::__construct() must be an instance of BlueFeather\EloquentFileMaker\Services\FileMakerConnection, instance of Illuminate\Database\MySqlConnection given

But if I do this in my controller (Query Builder aproach):

$data = FM::connection('filemaker')->layout('tabla')->get();
dd($data);

It works ok!

What am I doing wrong? Is it possible to use filemaker conn when using Eloquent if it's not the default project connection ?

Thanks in advance!!

laravel

filemaker

0 Answers

Your Answer

Accepted video resources