Extract Partial
- Open app.blade.php.
- Imagine you want to extract the below code into a navigational partial.
- Cut out that exact part of the code from app file and create a new file under views named nav.blade.php.
- Paste the code inside nav.
- How to bring navigation inside app? Use a keyword: @include.
- In app body part, write down @include('nav') :
Paste a List of Data
- For the routes, make sure to use controller as such:
- Then in HelloController.php, make a fake variable (just to test):
- Don't forget to add compact as the second string.
- Then, in service.blade.php, we only need to use php:
- For this method, you need to make sure service (the variable) actually exist.
- If there is no content in function service (in controller), instead of using @foreach, we can use @forelse.
- forelse allows us to add a new section which is @empty:
End
No comments:
Post a Comment
Komen atau sebarang pertanyaan di sini :)