Skip to content
Advertisement

Tag: laravel-8

Laravel: Passing data into route from database

I have created a theme system and I am trying to make the theme’s route file pull pages from the database and assign a route to it, below is my theme route file. The issue I am having is an Undefined variable: theme from my ThemeSettings::all model request. Route.php (In theme) ThemeSettings Migration These settings have worked in other parts

Laravel 8: Undefined offset error message

I’m working with Laravel Controllers: When I fill the form that comes with this Controller I get this message: ErrorException Undefined offset: 300 From this line: So what is the problem here? Answer The problem is probably this line: $image[$size] = $imagePath . “{$size}” . $filename; it should be: $images[$size] = $imagePath . “{$size}” . $filename;

Laravel Storage rename file before downlaod

I want to rename a file in the moment before download it in Laravel 8.0: I currently using the following code: But I can’t find a way to rename it before download it. I don’t want to rename the file in S3. Answer You can pass second argument to download method as below

Return JSON details of failed validation with Laravel 8

I’m creating an endpoint to store an Office with two fields: name, address. When validation fails laravel returns status 200 and a welcome page. It should return 4xx and error details with JSON, shouldn’t it? I tried to catch an exception (ValidationError) but I don’t get the error details. I’m testing it with unit test and postman: and with postman

Laravel 8 resource controller not fetching model

In Laravel 7 fetching a model was pretty straightforward, i just needed to setup mi resource route and make a get to the address: http://localhost/test/public/employee/1 But i cant make it work on Laravel 8, according to my understanding i just need to do this: But dd only returns an empty class: If i do this: dd returns the correct data:

Advertisement