Skip to content

Instantly share code, notes, and snippets.

@juniorb2ss
Created January 19, 2015 19:47
Show Gist options
  • Save juniorb2ss/da64d92205e53a914c40 to your computer and use it in GitHub Desktop.
Save juniorb2ss/da64d92205e53a914c40 to your computer and use it in GitHub Desktop.
class Wiki_Creature extends \Illuminate\Database\Eloquent\Model {
protected $table = 'wiki_creature';
protected $with = ['getloot'];
public function getLoot()
{
return $this->hasMany('DevAAC\Models\Wiki_Creature_Loot', 'name');
}
}
class Wiki_Creature_Loot extends \Illuminate\Database\Eloquent\Model {
protected $table = 'wiki_creature_loot';
public function getMonster()
{
return $this->belongsToMany('DevAAC\Models\Wiki_Creature','name');
}
}
//Codigo utilizado no router
$monster = Wiki_Creature::where('name', $name)->first();
dd($monster->getLoot);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment