CoursesController.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. namespace App\Admin\Controllers;
  3. use App\Models\Courses;
  4. use Encore\Admin\Controllers\AdminController;
  5. use Encore\Admin\Form;
  6. use Encore\Admin\Grid;
  7. use Encore\Admin\Show;
  8. class CoursesController extends AdminController
  9. {
  10. /**
  11. * Title for current resource.
  12. *
  13. * @var string
  14. */
  15. protected $title = 'Courses';
  16. /**
  17. * Make a grid builder.
  18. *
  19. * @return Grid
  20. */
  21. protected function grid()
  22. {
  23. $grid = new Grid(new Courses());
  24. $grid->column('id', __('Id'));
  25. $grid->column('isActive', __('IsActive'));
  26. $grid->column('name', __('Name'));
  27. $grid->column('price', __('Price'));
  28. $grid->column('period', __('Period'));
  29. $grid->column('forma', __('Forma'));
  30. $grid->column('level', __('Level'));
  31. $grid->column('hours', __('Hours'));
  32. $grid->column('teacher_id', __('Teacher id'));
  33. $grid->column('organisation_id', __('Organisation id'));
  34. $grid->column('created_at', __('Created at'));
  35. $grid->column('updated_at', __('Updated at'));
  36. return $grid;
  37. }
  38. /**
  39. * Make a show builder.
  40. *
  41. * @param mixed $id
  42. * @return Show
  43. */
  44. protected function detail($id)
  45. {
  46. $show = new Show(Courses::findOrFail($id));
  47. $show->field('id', __('Id'));
  48. $show->field('isActive', __('IsActive'));
  49. $show->field('name', __('Name'));
  50. $show->field('price', __('Price'));
  51. $show->field('period', __('Period'));
  52. $show->field('forma', __('Forma'));
  53. $show->field('level', __('Level'));
  54. $show->field('hours', __('Hours'));
  55. $show->field('teacher_id', __('Teacher id'));
  56. $show->field('organisation_id', __('Organisation id'));
  57. $show->field('created_at', __('Created at'));
  58. $show->field('updated_at', __('Updated at'));
  59. return $show;
  60. }
  61. /**
  62. * Make a form builder.
  63. *
  64. * @return Form
  65. */
  66. protected function form()
  67. {
  68. $form = new Form(new Courses());
  69. $form->switch('isActive', __('IsActive'));
  70. $form->text('name', __('Name'));
  71. $form->number('price', __('Price'));
  72. $form->number('period', __('Period'));
  73. $form->text('forma', __('Forma'));
  74. $form->text('level', __('Level'));
  75. $form->number('hours', __('Hours'));
  76. $form->number('teacher_id', __('Teacher id'));
  77. $form->number('organisation_id', __('Organisation id'));
  78. return $form;
  79. }
  80. }