假设,我有这些热情的模型
class User extends \LaravelBook\Ardent\Ardent
{
public $autoHydrateEntityFromInput = true;
protected $fillable = array('username', 'password', 'address');
protected $table = 'Users';
public static $relationsData = array(
'location' => array(self::HAS_ONE, 'Location');
}
class Location extends \LaravelBook\Ardent\Ardent
{
protected $fillable = array('address');
protected $table = 'Locations';
}现在,当我写这样的控制器代码,
$user = new User;
$user->address = Input::get('address');
$user->push();它不会将地址数据保存到address表
发布于 2014-08-25 06:10:37
你不展示Party模型吗?
此外,Input::get('address')什么也不做,它只是从输入返回地址。
我在这里假设,但我想你会想要这样的东西:
$user = new User;
$user->locations()->create(Input::only('address'));这将为用户创建一个新的位置,从输入中传入地址。
如果您正在尝试使用阿登特的自动水化技术,这可能会起到以下作用:
// Autohydrate the location model with input.
$location = new Location;
// Associate the new model with your user.
$user->locations()->save($location);https://stackoverflow.com/questions/25479570
复制相似问题