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…
Tag: laravel
Laravel how download file for Auth() user in dashboard view
I have big problem to enable Auth users download stored files in laravale storage. Users has in table users field id_message which is unique name of folder where user has file to download. What has to …
Saving selected option after validation in Laravel
I need help with saving a selected option after validation fails. Here is main.blade.php Controller looks like: I tried this, but it always returns only the last option: Answer If I understood you correctly you want to keep the previously selected option selected when the validation fails. Less repetitive sol…
Use blade value inside a component
At the moment I can successfully display some generated content in my blade view by calling a variable with a key, like this: What I would like to achieve, is to reuse the key for a class name for example. The reason for that is that I want to easily access this content with JavaScript by using a selector. So…
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 …
Grouped collection to associative array
I need to achive array in format showed at the end, I’m using laravel collections $query->get()->groupBy(‘COLOR’)->toArray(); array:2 [ “GREEN” => array:123 [ 0 => array:…
Laravel store Files from API with specific folder creation
My goal is create Laravel API to store Files, from VSTO POST request. But first need figure out how create unigue folders in laravel where to file store. From VSTO sending POST with File and parameter id_message. How to set Laravel Controller to store file as storage/app/MyFiles/{id_message}/file, and paramet…
Laravel if statement in query
I am beginner php developer. I have this code: I have error: “message”: “SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘== 1), client_company_…
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 i…
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 …