-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move schema to the SCHEMA class.. Duh
- Loading branch information
1 parent
9992b63
commit 31169e9
Showing
4 changed files
with
70 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php namespace Anomaly\FilesFieldType; | ||
|
||
use Anomaly\Streams\Platform\Addon\FieldType\FieldType; | ||
use Anomaly\Streams\Platform\Addon\FieldType\FieldTypeSchema; | ||
use Anomaly\Streams\Platform\Assignment\Contract\AssignmentInterface; | ||
use Illuminate\Database\Schema\Blueprint; | ||
|
||
/** | ||
* Class FilesFieldTypeSchema | ||
* | ||
* @link http://pyrocms.com/ | ||
* @author PyroCMS, Inc. <support@pyrocms.com> | ||
* @author Ryan Thompson <ryan@pyrocms.com> | ||
* @package Anomaly\FilesFieldType | ||
*/ | ||
class FilesFieldTypeSchema extends FieldTypeSchema | ||
{ | ||
|
||
/** | ||
* Add the field type's pivot table. | ||
* | ||
* @param Blueprint $table | ||
* @param AssignmentInterface $assignment | ||
*/ | ||
public function addColumn(Blueprint $table, AssignmentInterface $assignment) | ||
{ | ||
$table = $table->getTable() . '_' . $this->fieldType->getField(); | ||
|
||
$this->schema->dropIfExists($table); | ||
|
||
$this->schema->create( | ||
$table, | ||
function (Blueprint $table) { | ||
|
||
$table->integer('entry_id'); | ||
$table->integer('file_id'); | ||
$table->integer('sort_order')->nullable(); | ||
|
||
$table->primary(['entry_id', 'file_id']); | ||
} | ||
); | ||
} | ||
|
||
/** | ||
* Rename the pivot table. | ||
* | ||
* @param Blueprint $table | ||
* @param FieldType $from | ||
*/ | ||
public function renameColumn(Blueprint $table, FieldType $from) | ||
{ | ||
$this->schema->rename( | ||
$table->getTable() . '_' . $from->getField(), | ||
$table->getTable() . '_' . $this->fieldType->getField() | ||
); | ||
} | ||
|
||
/** | ||
* Drop the pivot table. | ||
* | ||
* @param Blueprint $table | ||
*/ | ||
public function dropColumn(Blueprint $table) | ||
{ | ||
$this->schema->dropIfExists( | ||
$table->getTable() . '_' . $this->fieldType->getField() | ||
); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.