Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.14 KB | None | 0 0
  1. <?php
  2.  
  3. namespace AppPagesResources;
  4.  
  5. use IlluminateHttpRequest;
  6. use LaravelNovaResource;
  7. use LaravelNovaFieldsID;
  8. use LaravelNovaFieldsText;
  9. use LaravelNovaFieldsHasMany;
  10.  
  11. class Page extends Resource
  12. {
  13. /**
  14. * The model the resource corresponds to.
  15. *
  16. * @var string
  17. */
  18. public static $model = 'AppPagesModelsPage';
  19.  
  20. /**
  21. * The single value that should be used to represent the resource when being displayed.
  22. *
  23. * @var string
  24. */
  25. public static $title = 'working_title';
  26.  
  27. /**
  28. * @var string
  29. */
  30. public static $group = 'Pages';
  31.  
  32. /**
  33. * The columns that should be searched.
  34. *
  35. * @var array
  36. */
  37. public static $search = [
  38. 'id', 'working_title'
  39. ];
  40.  
  41. /**
  42. * Eager load translations
  43. */
  44. public static $with = ['translations'];
  45.  
  46. /**
  47. * Get the fields displayed by the resource.
  48. *
  49. * @param IlluminateHttpRequest $request
  50. * @return array
  51. */
  52. public function fields(Request $request)
  53. {
  54. return [
  55. ID::make()->sortable(),
  56.  
  57. Text::make('Title', 'working_title')
  58. ->sortable()
  59. ->rules('required', 'max:256'),
  60.  
  61. HasMany::make('Translations', 'translations', AppPagesResourcesPageTranslation::class)
  62.  
  63. ];
  64. }
  65.  
  66. }
  67.  
  68. <?php
  69.  
  70. namespace CodedorPagesResources;
  71.  
  72. use IlluminateHttpRequest;
  73. use LaravelNovaResource;
  74. use LaravelNovaFieldsID;
  75. use LaravelNovaFieldsText;
  76.  
  77. class PageTranslation extends Resource
  78. {
  79. /**
  80. * The model the resource corresponds to.
  81. *
  82. * @var string
  83. */
  84. public static $model = 'CodedorPagesModelsPageTranslation';
  85.  
  86. /**
  87. * Hide resource from Nova's standard menu.
  88. * @var bool
  89. */
  90. public static $displayInNavigation = false;
  91.  
  92. /**
  93. * Get the fields displayed by the resource.
  94. *
  95. * @param IlluminateHttpRequest $request
  96. * @return array
  97. */
  98. public function fields(Request $request)
  99. {
  100. return [
  101. ID::make()->sortable(),
  102.  
  103. Text::make('Locale')
  104. ->sortable()
  105. ->rules('required', 'max:256')
  106. ];
  107. }
  108. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement