Skip to content

Tag: laravel

Laravel schedular: execute a command every second

I have a project that needs to send notifications via WebSockets continuously. It should connect to a device that returns the overall status in string format. The system processes it and then sends notifications based on various conditions. Since the scheduler can repeat a task as early as a minute, I need to…

Laravel findorfail() redirect

I have the following code : if we have an id in the DB table then that will come up with findorfail(), but if we add not existing id to the url like this : http://NewPro.dev/user-profile/24645645456 Then no query can be found and laravel page comes up. How can I redirect to some route if we have no id? Answer

Laravel seeder for table that is hardcoded

I have several tables in my database that are simply used for reference in my application. For example, a table that has two columns, State and State Abbreviation, and has all 50 states and their abbreviations as rows. I want to write seeders for these tables in Laravel, since I want these tables to exist whe…

Bootstrap modal validation in Laravel

I have a registrarion modal which opens on click. The inputs are validated on the view using required, etc. Thing is, there are other fields (also in other modals I’m not mentionig) in which I validate again rules in my controller. I’ve read that a good way of validating modals is using AJAX. I&#8…

Laravel – delete whole collection

I have images for articles, and when I am updating article I would like to check if the images are the same, if not I would like to delete them but if it is possible I would like to delete the whole collection without another query, something like what I have in the code below $images->delete();. This is m…