欢迎各位兄弟 发布技术文章
这里的技术是共享的
class Movie extends Eloquent { protected $table = 'movies'; protected $primaryKey = 'movie_id'; protected $fillable = array('movie_title','movie_date','movie_budget'); public function reviews() { return $this->hasMany('Review'); } public function people() { return $this->belongsToMany('People')->withPivot('job'); } }
{ protected $table = 'people'; protected $primaryKey = 'people_id'; public function movies() { return $this->belongsToMany('Movie'); } }
class Review extends \Eloquent { protected $primaryKey = 'review_id'; public function movie() { return $this->belongsTo('Movie'); } } use Illuminate\Auth\UserTrait;
use Illuminate\Auth\UserInterface; use Illuminate\Auth\Reminders\RemindableTrait; use Illuminate\Auth\Reminders\RemindableInterface; class User extends Eloquent implements UserInterface, RemindableInterface { use UserTrait, RemindableTrait; public static $rules = array('name' => 'required|min:5|max:10', 'email' => 'required|email|unique:users', // 'email' => 'required|email|unique:users,email' 'password' => 'required|between:6,12|confirmed' // 'password' => 'required|min:6|max:12' ); public static $messages = array( 'required' => ':attribute 字段是必填项', 'name.required' => '<strong>用户名</strong>字段是必填项' ); protected $primaryKey = 'user_id'; /** * The database table used by the model. * * @var string */ protected $table = 'users'; /** * The attributes excluded from the model's JSON form. * * @var array */ protected $hidden = array('password', 'remember_token'); }