-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
115 additions
and
1 deletion.
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
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,33 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Seeder; | ||
use TCG\Voyager\Models\DataRow; | ||
|
||
class DataRowsTableUnseeder extends Seeder | ||
{ | ||
/** | ||
* Will remove template attributes from JSON field. | ||
* | ||
* @return void | ||
*/ | ||
public function run() | ||
{ | ||
// fetch all rows where JSON not empty | ||
$rows = DataRow::whereNot('details', ''); | ||
|
||
// find every record for existence of Template attributes | ||
// and delete this key. | ||
foreach ($rows as $row) { | ||
$details = json_decode($row->details); | ||
|
||
// delete key if found | ||
if (isset($details->template)) { | ||
unset($details['template']); | ||
|
||
$row->details = json_encode($details); | ||
|
||
$row->save(); | ||
} | ||
} | ||
} | ||
} |
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,19 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Seeder; | ||
|
||
class DatabaseUnseeder extends Seeder | ||
{ | ||
/** | ||
* Run the database seeds. | ||
* | ||
* @return void | ||
*/ | ||
public function run() | ||
{ | ||
$this->seed('VoyagerTemplatesTableUnseeder'); | ||
$this->seed('MenuItemsTableUnseeder'); | ||
$this->seed('PermissionsTableUnseeder'); | ||
$this->seed('DataRowsTableUnseeder'); | ||
} | ||
} |
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,24 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Seeder; | ||
use TCG\Voyager\Models\Menu; | ||
use TCG\Voyager\Models\MenuItem; | ||
|
||
class MenuItemsTableUnseeder extends Seeder | ||
{ | ||
/** | ||
* Remove menu data. | ||
* | ||
* @return void | ||
*/ | ||
public function run() | ||
{ | ||
$url = '/admin/templates'; | ||
|
||
$menu = Menu::where('name', 'admin')->firstOrFail(); | ||
|
||
MenuItem::where('menu_id', $menu->id) | ||
->where('url', $url) | ||
->delete(); | ||
} | ||
} |
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,17 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Seeder; | ||
use TCG\Voyager\Models\Permission; | ||
|
||
class PermissionsTableUnseeder extends Seeder | ||
{ | ||
/** | ||
* Remove permissions data file. | ||
* | ||
* @return void | ||
*/ | ||
public function run() | ||
{ | ||
Permission::removeFrom('voyager_templates'); | ||
} | ||
} |
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,18 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Seeder; | ||
use LauncherHost\VoyagerTemplates\Models\Template as VoyagerTemplate; | ||
use TCG\Voyager\Models\DataType; | ||
|
||
class VoyagerTemplatesTableUnseeder extends Seeder | ||
{ | ||
/** | ||
* Remove Voyager Templates data. | ||
* | ||
* @return void | ||
*/ | ||
public function run() | ||
{ | ||
DataType::where('slug', 'templates')->delete(); | ||
} | ||
} |