mercredi 4 juillet 2018

Display name instead of id Laravel 5.6

I have two tables; RTAList and RTARegCompany. RTARegCompany contains foreign key rta_id referencing 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();
    });

I have to models RTAList and 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);
 }

Now, I want to show rta_name while adding RTA Registered Company. But i get error 'Trying to get nom-property;

In RTARegController, I have written this code..

 $rta = RTAList::where('rtaname')->get();

in add_company.blade.php, i want to show rta_name

  <input type="text" name="rta_id" id="rta_id" value="" disabled>

Help me to solve this problem...



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire