hasMany关系为null

时间:2017-05-12 20:31:25

标签: php laravel-5 has-many

我是Laravel 5.0的新手。 我试图在我的两个模型 protected override void OnCreate(Bundle savedInstanceState) { if (IsInvalidAppState()) { GoToLoginActivity(); base.OnCreate(null); } else { base.OnCreate(savedInstanceState); } } private void GoToLoginActivity() { var intent = new Intent(Application.Context, typeof(LoginActivity)); intent.SetFlags(ActivityFlags.ClearTop | ActivityFlags.NewTask | ActivityFlags.ClearTask); StartActivity(intent); } private bool IsInvalidAppState() { // Figure out if everything is initialized correctly } User之间建立一种非常关系。 如果修补我Device,结果为App\user::first()->device

我使用一些虚拟数据和单null工作填充了用户和设备表。 我在StackOverflow上搜索但我无法找到解决方案

这是我的find()

users table

我的public function up() { Schema::create('users', function(Blueprint $table) { $table->increments('id'); $table->string('name'); $table->string('email')->unique(); $table->string('password', 60); $table->rememberToken(); $table->timestamps(); }); }

devices table

public function up() { Schema::create('devices', function(Blueprint $table) { $table->increments('id'); $table->integer('user_id')->unsigned(); $table->foreign('user_id')->references('id')->on('users'); $table->double('lat', 15, 8); $table->double('lon', 15, 8); $table->timestamps(); }); }

中的函数
User Model

谢谢大家

1 个答案:

答案 0 :(得分:0)

代码是对的,我发现有时修补程序需要在代码更改后重新启动

相关问题