Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

hasMany relation in laravel

// function in model 
public function hasManyFunction()
{
  return $this->hasMany('AppModelsmodelName', 'targetedId');
}

// get data with hasMany relation in controller
$data = Post::with('hasManyFunction')->find(1)->;
Source by laravel.com #
 
PREVIOUS NEXT
Tagged: #hasMany #relation #laravel
ADD COMMENT
Topic
Name
8+1 =