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
4ecbef68
Commit
4ecbef68
authored
Apr 04, 2013
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1853 from cviebrock/table-macros
Add Macros to tables
parents
78af4569
906d0d85
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
1 deletion
+38
-1
table.php
laravel/database/schema/table.php
+38
-1
No files found.
laravel/database/schema/table.php
View file @
4ecbef68
...
...
@@ -39,6 +39,25 @@ class Table {
*/
public
$commands
=
array
();
/**
* The registered custom macros.
*
* @var array
*/
public
static
$macros
=
array
();
/**
* Registers a custom macro.
*
* @param string $name
* @param Closure $macro
* @return void
*/
public
static
function
macro
(
$name
,
$macro
)
{
static
::
$macros
[
$name
]
=
$macro
;
}
/**
* Create a new schema table instance.
*
...
...
@@ -422,4 +441,22 @@ class Table {
return
$this
->
columns
[]
=
new
Fluent
(
$parameters
);
}
}
\ No newline at end of file
/**
* Dynamically handle calls to custom macros.
*
* @param string $method
* @param array $parameters
* @return mixed
*/
public
function
__call
(
$method
,
$parameters
)
{
if
(
isset
(
static
::
$macros
[
$method
]))
{
array_unshift
(
$parameters
,
$this
);
return
call_user_func_array
(
static
::
$macros
[
$method
],
$parameters
);
}
throw
new
\Exception
(
"Method [
$method
] does not exist."
);
}
}
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