私は次のモデルを持っています:
class Movie extends Eloquent {
protected $primaryKey = "movie_id";
public function detail()
{
return $this->hasOne('Detail');
}
public function firstpage()
{
return $this->hasOne('Firstpage');
}
public function country()
{
return $this->belongsToMany('Countries','movies_countries','movie_id','country_id');
}
public function year()
{
return $this->hasOne('Years');
}
public function media() {
return $this->hasMany('Media');
}
}
これは対象のモデルです。
class Years extends Eloquent {
protected $table = 'movies_years';
protected $primaryKey = "relation_id";
public function movie()
{
return $this->belongsTo('Movie');
}
年のDBTableには、フィールド「movie_year」と「movie_id」があります
したがって、次の問題、または理解の問題があります。
モデルイヤーを新しいデータで更新しようとしていますが、うまくいかないようです。私は次のことを試しました:
$movies = Movie::find($tmp['movie_id']);
$movies->title = $tmp['title'];
$movies->title_product = $tmp['title_product'];
$movies->title_orginal = $tmp['title_original'];
$movies->year = array('movie_year' => $tmp['movieyears']);
$movies->push();
目は $movies->year 行にあり、他のすべては正常に動作します。
私も次のような愚かなことを試しました:
$movies->year() = array('movie_year' => $tmp['movieyears']);
Movie Model と関係がある Years Model の更新方法がわかりません。