Laravel.
http://laravel.com/docs/eloquent#working-with-pivot-tables
Laravel Pivot. , "Base", Eloquent. Eloquent Eloquent. , Pivot:
public function newPivot(Model $parent, array $attributes, $table, $exists)
{
return new YourCustomPivot($parent, $attributes, $table, $exists);
}
newPivot `` , Illuminate\Database\Eloquent\Model. Eloquent Illuminate\Database\Eloquent\Model, , .
class YourCustomPivot extends Illuminate\Database\Eloquent\Relations\Pivot {
protected function getHumanTimestampAttribute($column)
{
if ($this->attributes[$column])
{
return Carbon::parse($this->attributes[$column])->diffForHumans();
}
return null;
}
public function getHumanCreatedAtAttribute()
{
return $this->getHumanTimestampAttribute("created_at");
}
public function getHumanUpdatedAtAttribute()
{
return $this->getHumanTimestampAttribute("updated_at");
}
}
.
class Base extends Eloquent {
public function newPivot(Model $parent, array $attributes, $table, $exists)
{
return new YourCustomPivot($parent, $attributes, $table, $exists);
}
}