in my web application created with Laravel 8, I need to download an .xml file and the file name must be dynamically created, as per the title. this is because the file name is composed following a specific rule and having to include today’s date. $filename = ‘FirstPart_’.date(“Y-m-d”).’_000.xml’ so far to test the response and therefore the download I have
Tag: laravel
Get collection values without loop in Laravel
I have hotels and services tables with many to many relationship. I want to get services of specific hotel without using foreach or forelse loop from one line of code. This is how I tried to do that: Result I get: Result is an array of values, I want it to be without brackets and quotes. Any suggestions? Answer Solution:
Passing more than one variables from different controllers to a single view in Laravel 8
I need to pass two variables from two different controllers to a view and display the different values from the array variables to two different html form’s select options in Laravel 8. But Laravel doesn’t seem to allow pass two differnt variable to a single view. How do I slove this? Please find the error screenshot from this link. Controllers
PHP/Laravel FormRequests Types
I have a doubt about the FormRequest Class (I think it apply at other classes). I have a class which has a method init(). This method receive a VehicleRequest. I’m going to share a simplified version of the code: The class Car: The request I send (in car case) looks like: Now, in this example a Car class is initialized
How to capitalize a word that has all letters in as capital letters in css OR php
I have the following code and using css text-transform property with a value of capitalize or php ucwords() I get the title capitalized but when the title is provided with all letters as capitals it doesn’t work. How can I achieve the output to be capitalized regardless of the title provided? Answer A php solution would be to convert case
Extended Request missing data when reaching controller with type-hint
A lot of pieces to this so here’s the meat. Code very slightly tweaked for brevity. Extended class: Middleware: Routes: Controller: The /books1/5?foo=bar and frontend1() path works. $request is populated as expected. The /books2/5?foo=bar and frontend2() path is broken. $request has vast amounts of missing data, like it was instantiated with nothing. Evidently if I type-hint my subclass instead of
How to make a global variable for all blade laravel
Good Peoples. I have an issue with my project. In the layout blade, I need to fetch some data from the database. But I cannot pass variables as there has no route for the layout blade. It’s just a master blade. Is there any way to make a global variable and use it all blade? Thanks for the valuable replies.
PHP Laravel – Get array of models by search or return empty array
Very new to PHP and Laravel so this is probably a noob question. I know the $sites variable has content in it when I dd($sites); but when it comes to actually returning a value, I get nothing. Any thoughts what I am doing wrong? EDIT: The other function referenced above is here (shouldn’t really need it though). dd($sites) results: Answer
I Can’t show my database tables through migration command on powershell terminal (Windows 10)
I tried to run: php artisan migrate Also to connect to MySQL using terminal on Windows. I Got this error: .env file: I tried to change my DB_HOST to “localhost” but it didn’t work. When I want to show databases it shows those; But even if I create tables like these it didn’t see As you see; I even delete
How to hide a div if a value from db matches – Laravel
I want to hide a <div> element if the value is_admin === “0” in table admins. Here is my Controller Code I want to hide this div if is_admin === “0” Answer