Мое приложение демонстрирует это странное поведение в производственной среде, а не где-либо еще (происходит как в реальном интерфейсе, так и в тинкере):
>>> $db = DB::connection();
=> Illuminate\Database\MySqlConnection {#832}
>>> \App\User::resolveConnection()->select('select * from users');
=> [
{#838
+"id": 2,
+"deleted_at": "2018-04-10 20:47:07",
...perfectly normal data
},
{#848
+"id": 3,
+"deleted_at": "2018-04-10 20:47:07",
...perfectly normal data
},
]
>>> \App\User::resolveConnection()->select('select * from users');
=> [
{#846
+"id": 2,
...perfectly normal data
},
{#839
+"id": 3,
...perfectly normal data
},
]
>>> \App\User::all();
=> Illuminate\Database\Eloquent\Collection {#861
all: [],
}
Класс User довольно прост:
namespace App;
use Laravel\Passport\HasApiTokens;
use Illuminate\Notifications\Notifiable;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Spatie\Permission\Traits\HasRoles;
use Laravel\Cashier\Billable;
class User extends Authenticatable
{
use SoftDeletes;
use Billable;
use HasApiTokens, Notifiable, HasRoles;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'email', 'password', 'status'
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
public function organization()
{
return $this->hasOne(Organization::class);
}
}