barryvdh / laravel-ide-helper

IDE Helper for Laravel
MIT License
14.19k stars 1.16k forks source link

Properties don't show up in docblock in a multiple database setup #722

Closed raice closed 4 years ago

raice commented 5 years ago

Using Lavarel Ide helper for a long time now. So thank you for that, really helpful tool!

Now I have a small project with 2 databases that need to be synchronized. When I generate models It only shows: /**

I defined connection (protected $connection) and the table name (protected $table). Checked the connection, but it can get data from the database.

mfn commented 4 years ago

@raice is this still relevant?

ferdousanam commented 4 years ago

Is the issue fixed? I still can't generate model docblock by using multiple DB connection.

mfn commented 4 years ago

I'm using a project where some models use a different $connection and it works correctly.

Please share more details:

ferdousanam commented 4 years ago

I'm using a project where some models use a different $connection and it works correctly.

Please share more details:

  • code of the model
  • database configuration

app/Models/CMCommunity.php

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class CMCommunity extends Model
{
    protected $guarded = ['updated_at'];
    protected $primaryKey = 'COMMUNITYID';
    protected $connection = 'mysql_dev';
    protected $table = 'osusr_mlv_community';
    public $timestamps = false;
}

.env

DB_PROD_READ_HOST=localhost
DB_DEV_USERNAME=root
DB_DEV_PASSWORD=
DB_DEV_DATABASE=cm-external

config/database.php

'mysql_dev' => [
    'sticky'    => true,
    'driver' => 'mysql',
    'host' => env('DB_PROD_READ_HOST'),
    'port' => '3306',
    'database' => env('DB_DEV_DATABASE', ''),
    'username' => env('DB_DEV_USERNAME', 'root'),
    'password' => env('DB_DEV_PASSWORD', ''),
    'unix_socket' => env('DB_SOCKET', ''),
    'charset' => 'utf8',
    'collation' => 'utf8_unicode_ci',
    'prefix' => '',
    'prefix_indexes' => true,
    'strict' => false,
    'engine' => null,
    'options'   => [
        PDO::ATTR_EMULATE_PREPARES => true,
    ],
],
mfn commented 4 years ago

Not sure if any of these settings it. Try playing around, disabling sticky or remove options etc.

Pretty sure it's a local problem, are you sure it works on your dev machine? You env var containing "prod" sounds .. dangerous.

See here how the connection is resolved, in the end it uses exactly the property you give it:

ferdousanam commented 4 years ago

Not sure if any of these settings it. Try playing around, disabling sticky or remove options etc.

Pretty sure it's a local problem, are you sure it works on your dev machine? You env var containing "prod" sounds .. dangerous.

See here how the connection is resolved, in the end it uses exactly the property you give it:

Yeah. prod sounds dangerous. I have used it because the external database contains a huge amount of data and it is used in various subprojects. In my local development machine, I have some chunk of demo data from it. I know this is not an issue of a name but just let you know as you are curious about that. :smile:

Yes, It works in my development machine. I regularly use the database as most of the project page needs to load data from cm-external database.

mfn commented 4 years ago

Yes, It works in my development machine

I then fail to understand what this issue is about?

ferdousanam commented 4 years ago

Yes, It works in my development machine

I then fail to understand what this issue is about?

I am also thinking what is going on actually. I will try with a complete new project with multiple database connection and try to find out the issue.

mfn commented 4 years ago

I'm to close this issue in good faith:

Feel free to continue here or open a new issue once you've more details to share, thank you!