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
Tag: laravel-8
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 8: How To Use Intervention Image Library Properly
I want to use Intervention Image library for my Laravel project, so I just installed it via Composer and added this line of code to config/app.php: And also this line was added to aliases part: Now at my Controller I coded this: But as soon as I fill my form to check if it’s work or not, this error message
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:
Adding custom method to Laravel model causes create() to ignore attributes
In Laravel 8, I have already had a working DocumentPdf resource – at least I was able to create the object using DocumentPdf::create($attributes). Now I want to create a custom method in the model, a one that will fill the document with $data and send it to browser. While it works for existing documents, adding the method broke create() in
Laravel: Register is submitting null value for Username even when filled
When registering a new user, I want them to pick a unique username. Everything worked with the username when I used Jetstream but when I rebuilt with Laravel Fortify and Laravel UI, the username is null regardless of what the user enters in the field. Below I have included several samples of code used to add and register the username.
How can I redirect to different views based on user role or privilege in Laravel 8?
I put the function below in the LoginController class to redirect users to different views, and when after login I got this 419|expired page. Answer First put this in your LoginController class: use IlluminateSupportFacadesAuth; comment out this line protected $redirectTo =… and also add this function in the LoginController class: public function redirectPath() { }
Error when running multiple PHPUnit Tests in Laravel 8
Unit testing in a Laravel 8 project is throwing an error when more than one test is called. The issue is causing my tests to fail when I run more than one at once. When running a batch of tests the …