Snippet content copied to clipboard.
Are you sure to delete this snippet? No, don't delete
paste.mozilla.org allows you to share code snippets and notes with others. These pastes require a link to be viewed; they are not private. Anyone with the link is able to see the paste and also delete it.


Please refrain from sharing personal or sensitive information on this website to avoid it being viewed by other parties.

  1. /******************************
  2. * Controller
  3. */
  4. <?php
  5. namespace App\Http\Controllers\Twill;
  6. use A17\Twill\Models\Contracts\TwillModelContract;
  7. use A17\Twill\Services\Forms\Fields\Input;
  8. use A17\Twill\Services\Forms\Fields\BlockEditor;
  9. use A17\Twill\Services\Forms\Form;
  10. use A17\Twill\Http\Controllers\Admin\ModuleController as BaseModuleController;
  11. class PageController extends BaseModuleController
  12. {
  13. protected $moduleName = 'pages';
  14. public function getForm(TwillModelContract $model): Form
  15. {
  16. $form = parent::getForm($model);
  17. $form->add(
  18. Input::make()->name('description')->label('Description')
  19. );
  20. $form->add(
  21. BlockEditor::make()
  22. );
  23. $form->addFieldset(
  24. \A17\Twill\Services\Forms\Fieldset::make()
  25. ->title(trans('twill-metadata::form.titles.fieldset'))
  26. ->id('metadata')
  27. ->fields([
  28. \A17\Twill\Services\Forms\BladePartial::make()->view('twill-metadata::includes.metadata-fields')
  29. ->withAdditionalParams([
  30. 'metadata_card_type_options' => config('metadata.card_type_options'),
  31. 'metadata_og_type_options' => config('metadata.opengraph_type_options'),
  32. ]),
  33. ])
  34. );
  35. return $form;
  36. }
  37. }
  38. /*****************************************************
  39. * Model
  40. */
  41. <?php
  42. namespace App\Models;
  43. use A17\Twill\Models\Behaviors\HasBlocks;
  44. use A17\Twill\Models\Behaviors\HasSlug;
  45. use A17\Twill\Models\Behaviors\HasRevisions;
  46. use A17\Twill\Models\Behaviors\HasPosition;
  47. use A17\Twill\Models\Behaviors\Sortable;
  48. use A17\Twill\Models\Model;
  49. use A17\Twill\Models\Behaviors\HasMedias;
  50. use CwsDigital\TwillMetadata\Models\Behaviours\HasMetadata;
  51. class Page extends Model implements Sortable
  52. {
  53. use HasBlocks, HasSlug, HasRevisions, HasPosition, HasMetadata, HasMedias;
  54. public \Illuminate\Contracts\Foundation\Application|
  55. array|
  56. \Illuminate\Config\Repository|
  57. \Illuminate\Foundation\Application
  58. $metadataFallbacks = [];
  59. public $mediasParams = [
  60. 'cover' => [
  61. 'default' => [
  62. [
  63. 'name' => 'default',
  64. 'ratio' => 16 / 9,
  65. ],
  66. ],
  67. ],
  68. ];
  69. protected $fillable = [
  70. 'published',
  71. 'title',
  72. 'description',
  73. 'position',
  74. ];
  75. public $slugAttributes = [
  76. 'title',
  77. ];
  78. }
  79. /**********************************
  80. * Repository
  81. */
  82. <?php
  83. namespace App\Repositories;
  84. use A17\Twill\Repositories\Behaviors\HandleBlocks;
  85. use A17\Twill\Repositories\Behaviors\HandleSlugs;
  86. use A17\Twill\Repositories\Behaviors\HandleRevisions;
  87. use A17\Twill\Repositories\Behaviors\HandleMedias;
  88. use A17\Twill\Repositories\ModuleRepository;
  89. use App\Models\Page;
  90. use CwsDigital\TwillMetadata\Repositories\Behaviours\HandleMetadata;
  91. class PageRepository extends ModuleRepository
  92. {
  93. use HandleBlocks, HandleSlugs, HandleMedias, HandleRevisions, HandleMetadata;
  94. public function __construct(Page $model)
  95. {
  96. $this->model = $model;
  97. }
  98. }

Edit this Snippet