I need to create numeros files in Laravel each having it’s own incremental number:
page1.blade.php; page2.blade.php … ecc incrementing the number of the page automatically.
I can’t create the pages manually because i have to create more than 192 pages.
I know that’s not the best way, but i have to do it like so even if i don’t want to.
I want to create the pages using the function:
$page_number = $articles->id / 8
how can i do it?
$articles is the result of a query from mysql database.
2
Answers
First of fall – are you sure you’re using the right approach? I am struggling to find a reason why would you use so many blade files when they’re supposed to be only templates and not the pages themselves.
If you still think that this is the right approach, then you can implement it like this –
Please make sure you import the
File
facade for it work (use IlluminateSupportFacadesFile;
)Welcome to SO.
You don’t ever want to create that many files for articles. You want to create a template file and just provide data over there.
This is what templates look like. Read more here.
This is how you can get the data.