Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
L
laravel-mongodb
Project
Project
Details
Activity
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
sinan
laravel-mongodb
Commits
765e6670
Commit
765e6670
authored
Dec 19, 2013
by
Jens Segers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Testing SQL relations
parent
26927771
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
0 deletions
+24
-0
Model.php
src/Jenssegers/Mongodb/Model.php
+24
-0
No files found.
src/Jenssegers/Mongodb/Model.php
View file @
765e6670
...
@@ -131,6 +131,12 @@ abstract class Model extends \Illuminate\Database\Eloquent\Model {
...
@@ -131,6 +131,12 @@ abstract class Model extends \Illuminate\Database\Eloquent\Model {
*/
*/
public
function
hasOne
(
$related
,
$foreignKey
=
null
,
$localKey
=
null
)
public
function
hasOne
(
$related
,
$foreignKey
=
null
,
$localKey
=
null
)
{
{
// Check if it is a relation with an original model.
if
(
!
is_subclass_of
(
$related
,
'Jenssegers\Mongodb\Model'
))
{
return
parent
::
hasOne
(
$related
,
$foreignKey
,
$localKey
);
}
$foreignKey
=
$foreignKey
?:
$this
->
getForeignKey
();
$foreignKey
=
$foreignKey
?:
$this
->
getForeignKey
();
$instance
=
new
$related
;
$instance
=
new
$related
;
...
@@ -150,6 +156,12 @@ abstract class Model extends \Illuminate\Database\Eloquent\Model {
...
@@ -150,6 +156,12 @@ abstract class Model extends \Illuminate\Database\Eloquent\Model {
*/
*/
public
function
hasMany
(
$related
,
$foreignKey
=
null
,
$localKey
=
null
)
public
function
hasMany
(
$related
,
$foreignKey
=
null
,
$localKey
=
null
)
{
{
// Check if it is a relation with an original model.
if
(
!
is_subclass_of
(
$related
,
'Jenssegers\Mongodb\Model'
))
{
return
parent
::
hasMany
(
$related
,
$foreignKey
,
$localKey
);
}
$foreignKey
=
$foreignKey
?:
$this
->
getForeignKey
();
$foreignKey
=
$foreignKey
?:
$this
->
getForeignKey
();
$instance
=
new
$related
;
$instance
=
new
$related
;
...
@@ -170,6 +182,12 @@ abstract class Model extends \Illuminate\Database\Eloquent\Model {
...
@@ -170,6 +182,12 @@ abstract class Model extends \Illuminate\Database\Eloquent\Model {
*/
*/
public
function
belongsTo
(
$related
,
$foreignKey
=
null
,
$otherKey
=
null
,
$relation
=
null
)
public
function
belongsTo
(
$related
,
$foreignKey
=
null
,
$otherKey
=
null
,
$relation
=
null
)
{
{
// Check if it is a relation with an original model.
if
(
!
is_subclass_of
(
$related
,
'Jenssegers\Mongodb\Model'
))
{
return
parent
::
belongsTo
(
$related
,
$foreignKey
,
$otherKey
,
$relation
);
}
// If no relation name was given, we will use this debug backtrace to extract
// If no relation name was given, we will use this debug backtrace to extract
// the calling method's name and use that as the relationship name as most
// the calling method's name and use that as the relationship name as most
// of the time this will be what we desire to use for the relatinoships.
// of the time this will be what we desire to use for the relatinoships.
...
@@ -212,6 +230,12 @@ abstract class Model extends \Illuminate\Database\Eloquent\Model {
...
@@ -212,6 +230,12 @@ abstract class Model extends \Illuminate\Database\Eloquent\Model {
*/
*/
public
function
belongsToMany
(
$related
,
$collection
=
null
,
$foreignKey
=
null
,
$otherKey
=
null
,
$relation
=
null
)
public
function
belongsToMany
(
$related
,
$collection
=
null
,
$foreignKey
=
null
,
$otherKey
=
null
,
$relation
=
null
)
{
{
// Check if it is a relation with an original model.
if
(
!
is_subclass_of
(
$related
,
'Jenssegers\Mongodb\Model'
))
{
return
parent
::
belongsToMany
(
$related
,
$collection
,
$foreignKey
,
$otherKey
,
$relation
);
}
// If no relationship name was passed, we will pull backtraces to get the
// If no relationship name was passed, we will pull backtraces to get the
// name of the calling function. We will use that function name as the
// name of the calling function. We will use that function name as the
// title of this relation since that is a great convention to apply.
// title of this relation since that is a great convention to apply.
...
...
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