Skip to content

Instantly share code, notes, and snippets.

@nWidart
Created April 18, 2013 18:15
Show Gist options
  • Save nWidart/5414981 to your computer and use it in GitHub Desktop.
Save nWidart/5414981 to your computer and use it in GitHub Desktop.
<?php
// 1. Ajouté item X à la DB( items[id,name,modifier_id])
//
$item = new Item;
$item->name = "name";
$item->save();
// 2. Ajouté des modifiers à un Item X
//
$modifier = new Modifier;
$modifier->dexterity = 1000;
$modifier->strength = 800;
$modifier->vitality = 1500;
$modifier->intelligence = 1800;
$item = Item::find( $item_id );
$mods = $item->modifiers()->save($modifier);
// 3. Lié item X à un Character
//
$char = Character::find( $character_id );
$char->items()->attach( $item_id );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment