Commit Graph

85 Commits

Author SHA1 Message Date
Pavel Puchkin
3a46721eca Even more fluent eloquent model via magic setters
Now it is possible to use Eloquent's magic setters in chains. For example:

    $model->set_foo('foo')->take(10)->set_bar(some_function());
    // ...even though setters 'foo' and 'bar' are not defined on the model
2013-05-08 18:28:22 +11:00
Bernardo Rittmeyer
d46e19214b get_dirty() comparison is not type safe
get_dirty() must compare using Not Identical (!==) on place of Not Equal (!=).
For example, changing null to false don't make the model dirty.
2013-04-04 12:50:59 +03:00
Taylor Otwell
b0eb9a8b42 Fix bugs in Eloquent. 2013-01-05 16:45:34 -06:00
Jason Lewis
a422e06989 Find no longer needs to be defined on the model since the query catches it correctly.
Signed-off-by: Jason Lewis <jason.lewis1991@gmail.com>
2012-12-18 19:21:05 +11:00
Phill Sparks
8296f30c82 Update laravel/database/eloquent/model.php
Make query() available publicly via object and statically.
2012-11-27 12:33:01 +00:00
Franz Liedke
ff4b43c72f Ignore hidden relationships in to_array(). 2012-11-23 03:23:13 +01:00
crynobone
fd86aef25a Trivial improvement to Laravel, while it is not documented, it has been a standard in Laravel to use tab as indentation and new line for curly bracket
Signed-off-by: crynobone <crynobone@gmail.com>
2012-10-15 23:35:53 +08:00
Daniel Bøndergaard
54397e1bf2 Fixed wrong return type in phpdoc
Signed-off-by: Daniel Bøndergaard <db@helmstmt.com>
2012-09-28 10:10:35 +02:00
Taylor Otwell
02cb96a008 fix bug in eloquent model. 2012-09-27 17:44:03 -04:00
Taylor Otwell
fc9b0e1636 Merge pull request #1201 from JoostK/fix-1
Fixed a problem with `Eloquent::get_dirty`
2012-09-25 18:37:09 -07:00
RK
f148f6211c Fixing the array_get misspelling. 2012-09-24 10:35:07 -04:00
RK
258169ea00 [#1261] get_key now pulls from $original instead
This is in reference to issue #1261, where Model->get_key() returns
the key from the $attributes instead of from the $original property.
This breaks the functionality of a model with a primary key that may
change, as the SQL generated will be something like:

UPDATE `model` SET `key` = 'new-key' WHERE `key` = 'new-key';

Which won't update the model in the database.
2012-09-24 09:58:20 -04:00
JoostK
5f99c81035 Fixed a problem whith Eloquent::get_dirty
When you had a synched Eloquent model (e.g. without changed values) but
one of those values is `null`, then that value would be considered as
dirty. `Eloquent::changed` returns false, but the value is present in
`Eloquent::get_dirty`.

This fix makes sure that a `null` value in `$attributes` is only
present in `get_dirty` when it wasn't at all *set* in `$original`.
2012-09-09 20:52:33 +02:00
Callum McIntyre
6b73974505 Added new touch function to eloquent, updates timestamps and immediately saves
Signed-off-by: Callum McIntyre <mcintyre1994@gmail.com>
2012-09-03 21:44:16 +01:00
Taylor Otwell
db48fa4140 Merge pull request #1121 from mcintyre94/minor/unprotect-eloquent-timestamps
Minor/unprotect eloquent timestamps
2012-09-01 17:52:53 -07:00
Taylor Otwell
f34063c517 Fix bug in Eloquent to_array method. 2012-08-29 14:44:16 -05:00
Callum McIntyre
f8fdcd894a Changed timestamp function in eloquent/model.php to public 2012-08-19 15:15:42 +01:00
Taylor Otwell
1203473469 revert eloquent back to 3.2.3 2012-08-17 09:18:16 -05:00
Sergii Grebeniuk
690e8572aa phpdoc fixes 2012-08-03 18:17:48 +03:00
Dayle Rees
2c6ed23b45 fixing merge issues 2012-07-27 13:52:15 +01:00
Dayle Rees
3b09f99f9e Merge pull request #989 from dprvig/develop
Fixed various typos throughout laravel folder.
2012-07-27 03:54:40 -07:00
Josh Miller
0ea30993d4 Fixed various typos throughout laravel folder.
Signed-off-by: Josh Miller <josh@joshmmiller.com>
2012-07-21 20:18:55 -04:00
Franz Liedke
78920c5d27 Move automatic relationship parsing to Eloquent's query class. 2012-07-12 22:32:43 +02:00
Franz Liedke
71f8e4acc0 Fix a bug introduced in pull request #799 that caused eager loading constraints to stop working. 2012-07-12 23:16:22 +03:00
Chris Berthe
b325e954e3 Merge remote-tracking branch 'upstream/develop' into develop 2012-07-12 11:15:43 -04:00
Taylor Otwell
1879e6575a tweak eloquent model change method to not check types. 2012-07-10 08:02:08 -05:00
Taylor Otwell
e6ff7ba336 Merge pull request #901 from franzliedke/patch-18
Ignore NULL values when determining whether a model object is dirty
2012-07-06 17:07:58 -07:00
Taylor Otwell
a9d27ba79c Merge pull request #902 from JesseObrien/feature/eloquent-update-timestamp
Feature/eloquent update timestamp
2012-07-06 17:07:34 -07:00
Jesse O'Brien
1be274caa6 Change update function so it uses timestamp like save
Calling update() on an eloquent model has no way of overriding
the timestamp that should be set if $timestamps is set on the
model. This changes that so it uses the timestamp() function
which is an easy way to over ride the type of timestamps used.
2012-07-04 15:46:12 -04:00
Franz Liedke
f2ccc688fe Ignore NULL values when determining whether a model object is dirty. 2012-07-04 21:44:11 +03:00
Franz Liedke
a87bb86999 Fix a bug with Eloquent model classes and isset() when eager loading a relationship returns an empty result set. 2012-06-29 20:56:32 +03:00
Chris Berthe
f3d756476b Merge remote-tracking branch 'upstream/develop' into develop 2012-06-25 13:11:54 -04:00
Chris Berthe
fafaf724b0 Grammar/Vocabulary fixes
Signed-off-by: Chris Berthe <chrisberthe@gmail.com>
2012-06-13 11:19:20 -04:00
Jelle Sebreghts
ac8bd0829e Fix for https://github.com/laravel/laravel/issues/789 2012-06-11 20:00:46 +02:00
Jason Lewis
6d5239bf30 Missed a semi-colon.
Signed-off-by: Jason Lewis <jason.lewis1991@gmail.com>
2012-06-03 19:47:44 +09:30
Jason Lewis
b4db0f1b36 Small change moving array to a variable.
Signed-off-by: Jason Lewis <jason.lewis1991@gmail.com>
2012-06-03 19:45:49 +09:30
Jason Lewis
ab2fcb84ef Possible fix for issue #378.
Signed-off-by: Jason Lewis <jason.lewis1991@gmail.com>
2012-06-03 19:23:35 +09:30
Taylor Otwell
691d68ba54 improve / fix postgres support. 2012-05-30 14:23:27 -05:00
Taylor Otwell
b097b6c682 Fix to_array() in eloquent model. 2012-05-11 13:22:04 -05:00
Taylor Otwell
86fce099b3 Fixed belongs_to primary key bug. 2012-04-26 11:25:47 -05:00
Taylor Otwell
ca06582369 Add some events to Eloquent models. 2012-04-26 09:30:34 -05:00
Mark Huot
49384514ef The __get() magic method runs three checks before giving up but the __isset() method only runs two checks. This syncs the logic to ensure that __get() and __isset() are looking at the same possibilities. 2012-04-13 10:20:34 -03:00
Taylor Otwell
1847a369fb fixed eloquent datetime bug when determining dirty attributes. 2012-04-11 16:08:15 -05:00
Taylor Otwell
94b8582865 Add DateTime support to database binding layer.
Signed-off-by: Taylor Otwell <taylorotwell@gmail.com>
2012-04-10 15:03:42 -05:00
Taylor Otwell
fda19731c5 Fixing update handling in Has_Many and Has_One relationships.
Signed-off-by: Taylor Otwell <taylorotwell@gmail.com>
2012-04-10 11:26:03 -05:00
Taylor Otwell
1a5d4250d1 fix conflicts. 2012-04-10 10:10:31 -05:00
Joe Wallace
f7aee0ca2a Model::table() uses class_basename() helper - which properly discards namespaces on *nix systems
Signed-off-by: Joe Wallace <joew@atiba.com>
2012-04-09 11:28:40 -05:00
Taylor Otwell
eda46a815e fix eloquent model attribute resolution. 2012-04-04 10:33:24 -05:00
Taylor Otwell
369ecd80f7 Merge branch 'staging' into develop 2012-03-30 08:45:16 -05:00
Taylor Otwell
636d05665c fix merge conflicts. 2012-03-30 08:44:23 -05:00