samedi 10 avril 2021

how can i get field_name from the first table using relationship between two models ?? using laravel 6

i have two tables with two models and make a reactionship to can get the field_name from the first table :-

first Model:

    class KpcField extends Model
{
    public function concession(){
        return $this->hasMany(Concessions::class);
    }
}

second model :

 class Concessions extends Model
{
    public function kpcField(){
        return $this->belongsTo(KpcField::class);
    }
}

and trying to retreive the field_name in concession view but it showed ( Trying to get property 'field_name' of non-object )

using the foreach to show the data in table :

@foreach ($show_concessions as $show_concession)

<td>  </td>

@endforeach

Thanks for your cooperation



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire