fixing merge conflicts.
This commit is contained in:
@@ -385,6 +385,19 @@ abstract class Model {
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the model from the database.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
if ($this->exists)
|
||||
{
|
||||
return $this->query()->where(static::$key, '=', $this->get_key())->delete();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the update and creation timestamps on the model.
|
||||
*
|
||||
|
||||
@@ -170,9 +170,7 @@ class Has_Many_And_Belongs_To extends Relationship {
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$id = $this->base->get_key();
|
||||
|
||||
return $this->joining_table()->where($this->foreign_key(), '=', $id)->delete();
|
||||
return $this->pivot()->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -397,22 +397,24 @@ class Grammar extends \Laravel\Database\Grammar {
|
||||
* @param array $bindings
|
||||
* @return string
|
||||
*/
|
||||
public function shortcut($sql, $bindings)
|
||||
public function shortcut($sql, &$bindings)
|
||||
{
|
||||
// Laravel provides an easy short-cut notation for writing raw WHERE IN
|
||||
// statements. If (...) is in the query, it will be replaced with the
|
||||
// correct number of parameters based on the bindings.
|
||||
// correct number of parameters based on the query bindings.
|
||||
if (strpos($sql, '(...)') !== false)
|
||||
{
|
||||
for ($i = 0; $i < count($bindings); $i++)
|
||||
{
|
||||
// If the binding is an array, we can just assume it's used to
|
||||
// fill a "where in" condition, so we will just replace the
|
||||
// next place-holder in the query with the constraint.
|
||||
// If the binding is an array, we can just assume it's used to fill a
|
||||
// where in condition, so we'll just replace the next place-holder
|
||||
// in the query with the constraint and splice the bindings.
|
||||
if (is_array($bindings[$i]))
|
||||
{
|
||||
$parameters = $this->parameterize($bindings[$i]);
|
||||
|
||||
array_splice($bindings, $i, 1, $bindings[$i]);
|
||||
|
||||
$sql = preg_replace('~\(\.\.\.\)~', "({$parameters})", $sql, 1);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user