标签:
public function up() { Schema::create(‘articles‘, function (Blueprint $table) { $table->increments(‘id‘); $table->integer(‘user_id‘)->unsigned(); $table->string(‘title‘); $table->text(‘body‘); $table->timestamp(‘publishedAt‘); $table->timestamps(); $table->foreign(‘user_id‘) ->references(‘id‘) ->on(‘users‘) ->onDelete(‘cascade‘); }); }
//user public function articles(){ return $this->hasMany(‘App\article‘); } //article protected $fillable = [ ‘title‘, ‘body‘, ‘publishedAt‘, ‘user_id‘ //临时添加字段 ]; public function user() { return $this->belongsTo(‘App\user‘); }
{!! Form::hidden(‘user_id‘, 1) !!}
Route::controllers([ ‘auth‘=>‘Auth\AuthController‘, ‘password‘=>‘Auth\PasswordController‘ ]);
标签:
原文地址:http://www.cnblogs.com/fenle/p/4805941.html