я настраиваю «один на один» (полиморфный), как это
Мои модели:
namespace App;
use Illuminate\Database\Eloquent\Model;
class Payement extends Model{
protected $table = 'payements';
protected $primaryKey = 'id';
public function payementable(){
return $this->morphTo();
}}
class Recu extends Model{
protected $table = 'recus';
protected $primaryKey = 'id';
public function payement(){
return $this->morphOne('App\Payement', 'payementable');
}}
Схемы моих таблиц
Schema::create('recus', function (Blueprint $table) {
$table->bigIncrements('id');
});
Schema::create('payements', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('numero')->unique();
$table->bigInteger('payementable_id');
$table->string('payementable_type');
$table->timestamps();
});
проблема в том, что это работает
App\Payement::find(1)->payementable;
это возвращаемое значение null
App\Recu::find(1)->payement;
и это возвращаемое пустое собрание
Recu::first()->payement()->get()