mardi 17 décembre 2019

How can create dynamic fields in Laravel model

i need create a few fields dynamic in my model from other model, por example i have one model to properties table y other to properties rules, so how can join properties rules with properties table. other exmaple with code

 class Properties extends Model{
   protected $table = 'properties';
 }

 class PropertyRules extends Model{
   protected $table = 'properties_rules'
 }


  $properties = Properties::all();
  //i hope something like that

  $properties = [
     'id'=>1234,
     'name'=>'Property Name',
     'checkIn'=>'10:00',//come from propertiesRules
     'checkOut'=>'14:00',//come from propertiesRules
  ];

I do not want to use a foreign key to that, I won't join these fields as come from properties table



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire