Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
syncEnrollments
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Yeray Santana Hualde
syncEnrollments
Commits
eb5d68f2
Commit
eb5d68f2
authored
Jan 05, 2013
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1531 from jasonlewis/eloquent/bug/find
Allow find to be called anywhere on an Eloquent Model
parents
082fc0b3
a422e069
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
13 deletions
+17
-13
model.php
laravel/database/eloquent/model.php
+1
-13
query.php
laravel/database/eloquent/query.php
+16
-0
No files found.
laravel/database/eloquent/model.php
View file @
eb5d68f2
...
...
@@ -225,18 +225,6 @@ abstract class Model {
return
$model
->
query
()
->
where
(
$model
->
key
(),
'='
,
$id
)
->
update
(
$model
->
attributes
);
}
/**
* Find a model by its primary key.
*
* @param string $id
* @param array $columns
* @return Model
*/
public
function
_find
(
$id
,
$columns
=
array
(
'*'
))
{
return
$this
->
query
()
->
where
(
static
::
$key
,
'='
,
$id
)
->
first
(
$columns
);
}
/**
* Get all of the models in the database.
*
...
...
@@ -762,7 +750,7 @@ abstract class Model {
return
static
::
$$method
;
}
$underscored
=
array
(
'with'
,
'
find'
,
'
query'
);
$underscored
=
array
(
'with'
,
'query'
);
// Some methods need to be accessed both staticly and non-staticly so we'll
// keep underscored methods of those methods and intercept calls to them
...
...
laravel/database/eloquent/query.php
View file @
eb5d68f2
...
...
@@ -50,6 +50,22 @@ class Query {
$this
->
table
=
$this
->
table
();
}
/**
* Find a model by its primary key.
*
* @param mixed $id
* @param array $columns
* @return mixed
*/
public
function
find
(
$id
,
$columns
=
array
(
'*'
))
{
$model
=
$this
->
model
;
$this
->
table
->
where
(
$model
::
$key
,
'='
,
$id
);
return
$this
->
first
(
$columns
);
}
/**
* Get the first model result for the query.
*
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment