mirror of
https://github.com/laravel/laravel.git
synced 2025-02-20 11:53:14 +08:00
Fixed belongs_to primary key bug.
This commit is contained in:
parent
ca06582369
commit
86fce099b3
@ -390,6 +390,8 @@ abstract class Model {
|
||||
$query = $this->query()->where(static::$key, '=', $this->get_key());
|
||||
|
||||
$result = $query->update($this->get_dirty()) === 1;
|
||||
|
||||
if ($result) $this->fire_event('updated');
|
||||
}
|
||||
|
||||
// If the model does not exist, we will insert the record and retrieve the last
|
||||
@ -402,6 +404,8 @@ abstract class Model {
|
||||
$this->set_key($id);
|
||||
|
||||
$this->exists = $result = is_numeric($this->get_key());
|
||||
|
||||
if ($result) $this->fire_event('created');
|
||||
}
|
||||
|
||||
// After the model has been "saved", we will set the original attributes to
|
||||
|
@ -32,7 +32,7 @@ class Belongs_To extends Relationship {
|
||||
*/
|
||||
protected function constrain()
|
||||
{
|
||||
$this->table->where($this->base->key(), '=', $this->foreign_value());
|
||||
$this->table->where($this->model->key(), '=', $this->foreign_value());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -61,7 +61,7 @@
|
||||
- `Schema::drop` now accepts `$connection` as second parameter.
|
||||
- Added `Input::merge` method.
|
||||
- Added `Input::replace` method.
|
||||
- Added `eloquent.saved`, `eloquent.saving`, `eloquent.deleting`, and `eloquent.deleted` events to Eloquent models.
|
||||
- Added saving, saved, updating, creating, deleting, and deleted events to Eloquent.
|
||||
|
||||
<a name="upgrade-3.2"></a>
|
||||
## Upgrading From 3.1
|
||||
|
Loading…
x
Reference in New Issue
Block a user