As can be seen in the code, the previous function-based handler for the /app route is no longer required. Instead, requests on this route are simply forwarded to the new resource. Since in this example the list of user data is also the start page, no separate view is required. Both the linking of the resource and the forwarding are secured by the Auth middleware.
Finally, the page component needs to be morocco gambling data adapted so that the data can actually be displayed. The returned data is passed to the page component as a prop. In Svelte, props are declared using the export keyword. They can then be used within the component like any other variable. In Listing 8, the new content of the component is noted under resources/js/Pages/app/Home.svelte .
Listing 8: The new home page of the private area
For display purposes, the incoming data is saved under the name users . In the markup, the list of users is then iterated over using a {#each} block. The ID, name, email address and role are output for each data record. Buttons are also output for deleting and editing existing data, as well as for creating new users. The buttons point to operations that have not yet been implemented. To change this, the option to delete users will be introduced next.
delete user data - is to be deleted, a corresponding request is sent to the resource using the DELETE method. Since the operation has already been prepared in the data list, only the corresponding method called destroy needs to be implemented in the UserController . Eloquent makes the implementation very simple, as can be seen in Listing 9.
If a resource - like a user in this case
-
- Posts: 632
- Joined: Thu Jan 02, 2025 7:13 am