Skip to content

Resource controller

Alexander Stoimenov edited this page Jun 21, 2016 · 2 revisions

After running the admin:resource command the CMS creates the controller needed for managing the new resource. This controller should extends the AdminController which have some class variables that you can overwrite in the resource controller:

  • $sidebarItem - represents the array in the admin/sidebar.php config file. In most cases you will need to set the current sidebar item to active from the corresponding controller/function.
  • $viewData - an array that contains data relevant to the resource, used by the forms and views in the CMS:
    • pageTitle - mostly the resource name
    • createRoute, editRoute and deleteRoute - if you want to restrict the user from using these actions (not showing the corresponding buttons) you can just skip setting them
    • model - an empty resource model instance used in the index (list) view for displaying the table
    • record - the resource model instance used to populate create/edit form
    • actionVerb - a title used in the views, that describes the action that will be made by a form
    • formMethod - used by the form to the destinguish what kind of request you need to make
    • formAction - a route to which the form request will be made. Uses the 'dot notation' ('admin.users.create')
  • notify - function that accepts an array and flashes a notification in the view, in the array you can set:
    • type - success/danger/warning
    • title
    • description
Clone this wiki locally