Open peibinzhu opened 2 years ago
same problem
same problem
I created a model in ./app/Models/Model.php like this:
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Jenssegers\Mongodb\Eloquent\Model as Model_;
class Model extends Model_
{
use HasFactory;
public function __construct() {
$this->collection = env("DB_PREFIX") . parent::getTable();
}
}
Then other models extend from this model like this for example:
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use App\Models\Model;
class Post extends Model
{
use HasFactory;
}
It's worked for me.
Description:
I set
prefix
inconfig/database.php
file, but he doesn't work. My database table names are all prefixed, but I set them up, but it doesn't work, which makes me very distressed. hope it helps meSteps to reproduce
ll_
prefixin
config/database.php`.ll_log_boot_time_log
This is not the result I want, I hope the
prefix
set will work.I want to effect:
Expected behaviour
I want to be able to set the prefix to make it take effect.
Actual behaviour
I want to be able to set the prefix to make it take effect.