У меня есть две таблицы; RTAList и RTARegCompany. RTARegCompany содержит внешний ключ rta_id, ссылающийся на RTAList.
Schema::create('rta_list', function (Blueprint $table) {
$table->increments('rta_id');
$table->string('rta_name');
$table->string('rta_address');
$table->string('rta_phone');
$table->string('rta_email')->unique();
$table->integer('count');
$table->timestamps();
});
Schema::create('rta_reg_company', function (Blueprint $table) {
$table->increments('company_id');
$table->integer('rta_id')->unsigned();
$table->foreign('rta_id')
->references('id')
->on('rta_lists')
->onDelete('cascade');
$table->string('company_name');
$table->string('company_isin');
$table->string('company_script');
$table->string('company_address');
$table->string('company_phone');
$table->string('company_email');
$table->timestamps();
});
У меня есть модели RTAList и RTARegCompany.
protected $table = 'rta_list';
protected $fillable = ['rta_name', 'rta_address','rta_phone','rta_email'];
protected $table = 'rta_reg_company';
protected $fillable = ['rta_id', 'company_name','company_isin','company_script','company_address','company_phone','company_email'];
public function rtaname(){
return $this->belongsTo(RTAList::class);
}
Теперь я хочу показать имя rta_name при добавлении зарегистрированной компании RTA. Но я получаю сообщение об ошибке "Попытка получить nom-свойство;
В RTARegController я написал этот код ..
$rta = RTAList::where('rtaname')->get();
в add_company.blade.php, я хочу показать rta_name
<input type="text" name="rta_id" id="rta_id" value="{{ $rta->rtaname->rta_name }}" disabled>
Помогите мне решить эту проблему ...