Skip to content
Advertisement

Tag: laravel

Assign filename dynamically in a response

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

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:

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

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

Advertisement