Overview

Namespaces

  • Composer
    • Autoload
  • Illuminate
    • Support
      • Contracts
      • Facades
  • Laravella
    • Crud
      • Exceptions
      • Facades
  • None
  • PHP

Classes

  • CrudDatabaseSeeder
  • CrudInstallCommand
  • CrudSeeder
  • CrudServiceProvider
  • CrudUpdateCommand
  • DbGopher
  • Log
  • Options
  • Params
  • PostCrudSeeder
  • SeedActions
  • SeedAssets
  • SeedGroups
  • SeedLogs
  • SeedMenus
  • SeedObjects
  • SeedOptions
  • SeedPageTypes
  • SeedSeverities
  • SeedTables
  • SeedUsergroups
  • SeedUsers
  • SeedViews
  • UpdateCMSFields
  • UpdateReferences
  • Overview
  • Namespace
  • Class
  • Tree
 1: <?php namespace Laravella\Crud;
 2: 
 3: use Laravella\Crud\Log;
 4: use \Seeder;
 5: use \DB;
 6: 
 7: class UpdateCMSFields extends CrudSeeder {
 8: 
 9:     private function updateField($tableName, $fieldName, $widgetType)
10:     {
11:         $tableId = DB::table('_db_tables')->where('name', $tableName)->pluck('id');
12: 
13:         //get the id of the primary key field in _db_fields
14:         //for each field in the _db_fields table there will thus be a reference to 
15:         $widgetTypeId = DB::table('_db_widget_types')
16:                 ->where('name', $widgetType)
17:                 ->pluck('id');
18:         
19:         //get the id of the primary key field in _db_fields
20:         //for each field in the _db_fields table there will thus be a reference to 
21:         $displayTypeId = DB::table('_db_display_types')
22:                 ->where('name', 'widget')
23:                 ->pluck('id');
24:         
25:         DB::table('_db_fields')
26:                 ->where('table_id', $tableId)
27:                 ->where('name', $fieldName)
28:                 ->update(array('widget_type_id' => $widgetTypeId, 'display_type_id' => $displayTypeId));
29:     }
30: 
31:     public function run()
32:     {
33: //        $this->updateField('contents', 'content', 'ckeditor');
34: //        $this->updateField('contents', 'excerpt', 'textarea');
35: //        $this->updateField('medias', 'thumbnail', 'thumbnail');
36:     }
37: 
38: }
39: 
40: ?>
crud API documentation generated by ApiGen 2.8.0