Created
July 21, 2016 19:30
-
-
Save mikhailkozlov/d472056e43cbe7e5e9a9c50e3d28e067 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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