Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
UserAdminV2
Overview
Overview
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
庄欣
UserAdminV2
Commits
dc92dd26
Commit
dc92dd26
authored
13 years ago
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding auto detection of intermediate table names.
Signed-off-by: Taylor Otwell <taylorotwell@gmail.com>
parent
c3d95122
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
2 deletions
+33
-2
laravel/database/eloquent/model.php
+1
-1
laravel/database/eloquent/relationships/has_many_and_belongs_to.php
+17
-1
laravel/helpers.php
+15
-0
No files found.
laravel/database/eloquent/model.php
View file @
dc92dd26
...
...
@@ -264,7 +264,7 @@ abstract class Model {
* @param string $other
* @return Relationship
*/
public
function
has_many_and_belongs_to
(
$model
,
$table
,
$foreign
=
null
,
$other
=
null
)
public
function
has_many_and_belongs_to
(
$model
,
$table
=
null
,
$foreign
=
null
,
$other
=
null
)
{
return
new
Has_Many_And_Belongs_To
(
$this
,
$model
,
$table
,
$foreign
,
$other
);
}
...
...
This diff is collapsed.
Click to expand it.
laravel/database/eloquent/relationships/has_many_and_belongs_to.php
View file @
dc92dd26
...
...
@@ -39,12 +39,28 @@ class Has_Many_And_Belongs_To extends Relationship {
{
$this
->
other
=
$other
;
$this
->
joining
=
$table
;
$this
->
joining
=
$table
?:
$this
->
joining
(
$model
,
$associated
)
;
parent
::
__construct
(
$model
,
$associated
,
$foreign
);
}
/**
* Determine the joining table name for the relationship.
*
* By default, the name is the models sorted and concatenated with an underscore.
*
* @return string
*/
protected
function
joining
(
$model
,
$associated
)
{
$models
=
array
(
class_basename
(
$model
),
class_basename
(
$associated
));
sort
(
$models
);
return
strtolower
(
$models
[
0
]
.
'_'
.
$models
[
1
]);
}
/**
* Get the properly hydrated results for the relationship.
*
* @return array
...
...
This diff is collapsed.
Click to expand it.
laravel/helpers.php
View file @
dc92dd26
...
...
@@ -377,6 +377,21 @@ function root_namespace($class, $separator = '\\')
}
/**
* Get the "class basename" of a class or object.
*
* The basename is considered the name of the class minus all namespaces.
*
* @param object|string $class
* @return string
*/
function
class_basename
(
$class
)
{
if
(
is_object
(
$class
))
$class
=
get_class
(
$class
);
return
basename
(
$class
);
}
/**
* Return the value of the given item.
*
* If the given item is a Closure the result of the Closure will be returned.
...
...
This diff is collapsed.
Click to expand it.
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