Skip to content

Instantly share code, notes, and snippets.

@d3v2a
Created October 28, 2016 01:09
Show Gist options
  • Save d3v2a/967e9bd51282fe27dbbcb421eddb5b41 to your computer and use it in GitHub Desktop.
Save d3v2a/967e9bd51282fe27dbbcb421eddb5b41 to your computer and use it in GitHub Desktop.
bug with phpunit
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class FirstModel extends Model
{
protected $table = 'FirstModels';
public $timestamps = false;
protected $connection = 'db1';
}
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class SecondModel extends Model
{
public function firstModels()
{
$defaultDb = config('database.default');
$db = config('database.connections.' . $defaultDb . '.database');
return $relation = $this->belongsToMany(
\App\FirstModel::class,
$db . '.secound_model_First_model',
'second_model_id',
'first_model_id'
)->withPivot('type');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment