Cara mengatasi Property [group_code] does not exist on this collection instance. di LARAVEL

Screenshot (501).png

Coa.php (MODEL)

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Coa extends Model
{
    protected $table = "coa_group";
    protected $fillable = ['group_code','description'];
    // protected $primaryKey = 'group_code';
    public $timestamps = false;

    public function coasub(){
        return $this->hasMany('App\Coasub');
        // return $this->hasMany(Coasub::class);
    }
}

Coasub.php (MODEL)

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Coasub extends Model
{
    protected $table = "coa_sub_group";
    protected $fillable = ['group_code','sub_group_code','description'];
    public $timestamps = false;

    public function coa(){
        return $this->belongsTo('App\Coa');
        // return $this->belongsTo(Coa::class,'group_code');
    }
}

Controller

    public function coaindex()
    {

        $coa_group = Coa::all();
        $coa_sub_group = Coasub::all();
        return view('accounting.coa.index', compact('data','coa_group','coa_sub_group'));
    }

Views

<td><b>{{$coa_sub_group->group_code->group_code}}</b></td>
avatar dynemix
@dynemix

43 Kontribusi 5 Poin

Dipost 3 tahun yang lalu

Belum ada Jawaban. Jadi yang pertama Jawaban

Login untuk ikut Jawaban