Skip to content

Instantly share code, notes, and snippets.

@mikhailkozlov
Created July 21, 2016 19:30
Show Gist options
  • Save mikhailkozlov/d472056e43cbe7e5e9a9c50e3d28e067 to your computer and use it in GitHub Desktop.
Save mikhailkozlov/d472056e43cbe7e5e9a9c50e3d28e067 to your computer and use it in GitHub Desktop.
class Chinas{
public function botella()
{
return $this->belongsTo('App\Botellas','botellas_id');
}
}
class Botellas{
public function chinas()
{
return $this->hasMany('App\Chinas','botellas_id');
}
}
// this should work now
function index()
{
$chinas = Chinas::all();
foreach ($chinas as $china) {
echo $china->name . " ". $china->botella->name . "<br/>";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment