Removed add_ magic method from eloquent model as this will be a 3.2 feature.
This commit is contained in:
parent
a915e24b62
commit
ba4d1a89c8
|
@ -17,6 +17,8 @@ class Blade {
|
||||||
'structure_closings',
|
'structure_closings',
|
||||||
'else',
|
'else',
|
||||||
'includes',
|
'includes',
|
||||||
|
'render_each',
|
||||||
|
'render',
|
||||||
'yields',
|
'yields',
|
||||||
'yield_sections',
|
'yield_sections',
|
||||||
'section_start',
|
'section_start',
|
||||||
|
@ -265,6 +267,32 @@ protected static function compile_includes($value)
|
||||||
return preg_replace($pattern, '$1<?php echo view$2->with(get_defined_vars()); ?>', $value);
|
return preg_replace($pattern, '$1<?php echo view$2->with(get_defined_vars()); ?>', $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rewrites Blade @render statements into valid PHP.
|
||||||
|
*
|
||||||
|
* @param string $value
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected static function compile_render($value)
|
||||||
|
{
|
||||||
|
$pattern = static::matcher('render');
|
||||||
|
|
||||||
|
return preg_replace($pattern, '$1<?php echo render$2; ?>', $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rewrites Blade @render_each statements into valid PHP.
|
||||||
|
*
|
||||||
|
* @param string $value
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected static function compile_render_each($value)
|
||||||
|
{
|
||||||
|
$pattern = static::matcher('render_each');
|
||||||
|
|
||||||
|
return preg_replace($pattern, '$1<?php echo render_each$2; ?>', $value);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rewrites Blade @yield statements into Section statements.
|
* Rewrites Blade @yield statements into Section statements.
|
||||||
*
|
*
|
||||||
|
|
|
@ -136,9 +136,9 @@ public function fill($attributes)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the original attribute values have not been set, we will set them to
|
// If the original attribute values have not been set, we will set
|
||||||
// the values passed to this method allowing us to quickly check if the
|
// them to the values passed to this method allowing us to easily
|
||||||
// model has changed since hydration of the original instance.
|
// check if the model has changed since hydration.
|
||||||
if (count($this->original) === 0)
|
if (count($this->original) === 0)
|
||||||
{
|
{
|
||||||
$this->original = $this->attributes;
|
$this->original = $this->attributes;
|
||||||
|
@ -308,6 +308,32 @@ public function has_many_and_belongs_to($model, $table = null, $foreign = null,
|
||||||
return new Has_Many_And_Belongs_To($this, $model, $table, $foreign, $other);
|
return new Has_Many_And_Belongs_To($this, $model, $table, $foreign, $other);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Save the model and all of its relations to the database.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function push()
|
||||||
|
{
|
||||||
|
$this->save();
|
||||||
|
|
||||||
|
// To sync all of the relationships to the database, we will simply spin through
|
||||||
|
// the relationships, calling the "push" method on each of the models in that
|
||||||
|
// given relationship, this should ensure that each model is saved.
|
||||||
|
foreach ($this->relationships as $name => $models)
|
||||||
|
{
|
||||||
|
if ( ! is_array($models))
|
||||||
|
{
|
||||||
|
$models = array($models);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($models as $model)
|
||||||
|
{
|
||||||
|
$model->push();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save the model instance to the database.
|
* Save the model instance to the database.
|
||||||
*
|
*
|
||||||
|
@ -612,14 +638,6 @@ public function __call($method, $parameters)
|
||||||
$this->attributes[substr($method, 4)] = $parameters[0];
|
$this->attributes[substr($method, 4)] = $parameters[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the method begins with "add_", we will assume that the developer is
|
|
||||||
// adding a related model instance to the model. This is useful for
|
|
||||||
// adding all of the related models and then saving at once.
|
|
||||||
elseif (starts_with($method, 'add_'))
|
|
||||||
{
|
|
||||||
$this->relationships[substr($method, 4)][] = $parameters[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Finally we will assume that the method is actually the beginning of a
|
// Finally we will assume that the method is actually the beginning of a
|
||||||
// query, such as "where", and will create a new query instance and
|
// query, such as "where", and will create a new query instance and
|
||||||
// call the method on the query instance, returning it after.
|
// call the method on the query instance, returning it after.
|
||||||
|
|
|
@ -96,7 +96,7 @@ protected function fresh_model($attributes = array())
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function foreign_key()
|
public function foreign_key()
|
||||||
{
|
{
|
||||||
return static::foreign($this->base, $this->foreign);
|
return static::foreign($this->base, $this->foreign);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue