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
26927771
Commit
26927771
authored
Dec 14, 2013
by
Jens Segers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding nullable method to Blueprint, fixes #90
parent
26b19c63
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
6 deletions
+32
-6
Blueprint.php
src/Jenssegers/Mongodb/Schema/Blueprint.php
+16
-6
SchemaTest.php
tests/SchemaTest.php
+16
-0
No files found.
src/Jenssegers/Mongodb/Schema/Blueprint.php
View file @
26927771
...
...
@@ -44,7 +44,7 @@ class Blueprint extends \Illuminate\Database\Schema\Blueprint {
*
* @param string|array $columns
* @param array $options
* @return
bool
* @return
Blueprint
*/
public
function
index
(
$columns
=
null
,
$options
=
array
())
{
...
...
@@ -72,7 +72,7 @@ class Blueprint extends \Illuminate\Database\Schema\Blueprint {
* Indicate that the given index should be dropped.
*
* @param string|array $columns
* @return
bool
* @return
Blueprint
*/
public
function
dropIndex
(
$columns
=
null
)
{
...
...
@@ -90,7 +90,7 @@ class Blueprint extends \Illuminate\Database\Schema\Blueprint {
* Specify a unique index for the collection.
*
* @param string|array $columns
* @return
bool
* @return
Blueprint
*/
public
function
unique
(
$columns
=
null
,
$name
=
null
)
{
...
...
@@ -104,7 +104,7 @@ class Blueprint extends \Illuminate\Database\Schema\Blueprint {
* Specify a non blocking index for the collection.
*
* @param string|array $columns
* @return
bool
* @return
Blueprint
*/
public
function
background
(
$columns
=
null
)
{
...
...
@@ -118,7 +118,7 @@ class Blueprint extends \Illuminate\Database\Schema\Blueprint {
* Specify a sparse index for the collection.
*
* @param string|array $columns
* @return
bool
* @return
Blueprint
*/
public
function
sparse
(
$columns
=
null
)
{
...
...
@@ -134,7 +134,7 @@ class Blueprint extends \Illuminate\Database\Schema\Blueprint {
*
* @param string|array $columns
* @param int $seconds
* @return
bool
* @return
Blueprint
*/
public
function
expire
(
$columns
,
$seconds
)
{
...
...
@@ -168,6 +168,16 @@ class Blueprint extends \Illuminate\Database\Schema\Blueprint {
$this
->
collection
->
drop
();
}
/**
* Allow an attribute to be null, does not do anything.
*
* @return Blueprint
*/
public
function
nullable
()
{
return
$this
;
}
/**
* Add a new column to the blueprint.
*
...
...
tests/SchemaTest.php
View file @
26927771
...
...
@@ -92,6 +92,22 @@ class SchemaTest extends PHPUnit_Framework_TestCase {
$this
->
assertEquals
(
60
,
$index
[
'expireAfterSeconds'
]);
}
public
function
testSoftDeletes
()
{
Schema
::
collection
(
'newcollection'
,
function
(
$collection
)
{
$collection
->
softDeletes
();
});
Schema
::
collection
(
'newcollection'
,
function
(
$collection
)
{
$collection
->
string
(
'email'
)
->
nullable
()
->
index
();
});
$index
=
$this
->
getIndex
(
'newcollection'
,
'email'
);
$this
->
assertEquals
(
1
,
$index
[
'key'
][
'email'
]);
}
public
function
testFluent
()
{
Schema
::
collection
(
'newcollection'
,
function
(
$collection
)
...
...
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