Questions tagged [laravel]

Laravel is an open-source PHP web development framework created by Taylor Otwell. Laravel helps you create applications using simple, expressive syntax.

Filter by
Sorted by
Tagged with
1
vote
3answers
33 views

Laravel controller Single Responsibility principle

I have a method in Laravel controller. How can I improve this code? How can I implement single responsibilty here or maybe there are some other tips I can use in this code? I know that controller ...
3
votes
1answer
45 views

Laravel - Repetitive code in store and update functions

I am working on a system and I can see myself using repetitive code that does not look right. I want to clean up my code but I don't really know many ways to do so. I have 2 methods (store and update)....
4
votes
2answers
53 views

Map associative array to another array php

I have an associative array of the states of some country, and the states names are the keys: ...
1
vote
0answers
30 views

Laravel 5.8: prevent duplicated code

Sometimes we have this code blocks that is repeated in the same controller again and again, I reviewed the Repository Pattern but I didn't understand how to deal with some kind of these duplication. ...
4
votes
1answer
88 views

Laravel controller method that searches jobs using variable criteria

I have custom code where I check request params for existing and make query to database with model ...
0
votes
0answers
31 views

Export an Excel file using Laravel-Excel

I have this piece of code that is used to export an Excel file using Laravel-Excel. But I have doubts about it for the long run. Can the server handle it if there are a hundred requests? ...
0
votes
0answers
27 views

Using localized pluralization in Laravel mailable

I am using blade templates from Laravel inside a Mailable class. The text of the mail is dynamic and depends on the number of users. The number of users is fixed per mail, but I need to translate each ...
3
votes
2answers
62 views

Using PHP goto Labels for code folding

I've been using PHP labels in my Controllers for code folding. PHP labels are actually used with goto statements. But I'm using labels only because it's so much ...
1
vote
0answers
31 views

Ecommerce site shipping data

I have REST API written on laravel and front end on vue.js. It is a dashboard for an ecommerce store where you can connect to post shipment service API to upload order shipment data and get tracking ...
1
vote
1answer
32 views

Laravel build a route from a model

I've created a library, TomHart/laravel-route-from-model, and looking to get a review on it. As well as the usual code review, I'm also looking for feedback from a users point of view, if you were to ...
0
votes
0answers
28 views

Simple laravel class for data save, validating and search, with controller

Order class - stores data, validates it, saves relations data, returns search data: ...
1
vote
0answers
29 views

what is the correct way to pass 3 where () conditions in the same function, multiple filters | eloquente - laravel

see: https://stackoverflow.com/questions/58882690/what-is-the-correct-way-to-pass-3-where-conditions-in-the-same-function-mult/58883277?noredirect=1#comment104033826_58883277 to better understand ...
2
votes
1answer
115 views

Adding an item to a container, but first a lot of checks

First time on this exchange, so giving this a title was already a challenge. So let's start at the beginning. This kind professor Güneş Erdoğan has published an CLP (Container Loading Problem) solver. ...
1
vote
0answers
22 views

Providing JavaScript Configuration (Laravel config() style)

This may be better suited on Stackoverflow, in which case, please let me know and I will move it over... Background Consider the following file structure: ...
1
vote
1answer
40 views

How to splits blade files that contain javascript? [closed]

I have these scripts ...
3
votes
0answers
47 views

Divide / Split single file .php into clean code parts

I wrote a page with Laravel to manage projects with Scrumpoker through blade syntax with controllers, models and Vue.js. My problem is that I wrote the actual Scrumpoker in a single file.php file and ...
1
vote
0answers
27 views

How should I instantiate a class using composition with Laravel IOC container? [closed]

I have an Analytics class that performs some actions to compile analytics data. Here is that class: ...
2
votes
0answers
41 views

Laravel testing for compatibility between old and new password-hashing schemes

I currently have an event listener tied to Laravel's Attempting class. The listener is designed to rehash an old password to something newer. The current DB stores ...
2
votes
1answer
29 views

Laravel controller methods for registering businesses and stylists

I use the Laravel API and want make messy code cleaner. I have a form for registering business and businessOwner. And stylist who is working under this business registering from same function. And ...
1
vote
1answer
61 views

A method to get a document's path

I have a model called Document, in this I have a method that I use throughout my website to get the full path to the specific document: ...
1
vote
5answers
90 views

PHP function to obtain model_name from Namespace\To\ModelName

Would there be a more clear/efficient way to write ...
2
votes
0answers
40 views

A cleaner way to track model changes

The application I'm currently working on have two main user types, let's say user and reviewer. I need to create a functionality ...
3
votes
1answer
30 views

List products based on slug and sidebar filters

This method shows the list of manufacturers' offered products based on the slug and sidebar filters. Most of the time I have to write the same query with only some changes: you can say I am repeating ...
0
votes
2answers
75 views

Asynchronous query to load products from laravel controller

The following code works fine. When a user clicks on an element, an AJAX request is made, which will return the query result. The results are being displayed in a view. I read many articles where ...
1
vote
1answer
60 views

Laravel executing 100 queries on page load?

Debugged my page load (was taking 4s...) and I was running 94 queries. 30 of them were the same. I've refactored a little by caching results, but how can I further refactor this class? The project is ...
1
vote
0answers
97 views

PHP / Laravel - Using Python to image manipulation

I have a simple job class in Laravel, that: Get all the images in a folder /original Perform some image manipulation on each image Save each image in a new folder ...
2
votes
0answers
52 views

PHP - Transforming text content according to rules then persisting to database

I have a web application where my users can upload text documents and emails into what I call Streams. A stream is like a "stack", that holds all emails / documents. My users can then add ...
1
vote
1answer
230 views

PHP Laravel - Improving and refactoring code to Reduce Queries

Improve Request to Reduce Queries I have a web application, where users can upload Documents or Emails, to what I call a Strema. The users can then define document fields email fields to the stream, ...
1
vote
0answers
36 views

Handling Multiple Asynchronous Events

I have a web application where users can uploads image documents. Now, after a new document is uploaded into the system, it should: 1) Be optimized. (OCR) 2) Perform various rules on the OCR output....
1
vote
0answers
46 views

updatePositions() Laravel controller method

I have been trying to implement good 'OOP' and coding standards, but I always end up with bloated controllers. How could I clean this controller method? ...
1
vote
1answer
64 views

A PHP Controller, which feels to 'array-like', in Laravel

This is a controller, which receives the validated input from a http request, then finds the assorted model and for each translation key in the received data, it will add it to the model. ...
2
votes
1answer
67 views

My code get data from database using AJAX and return to view

My code get data from database using AJAX the problem is i want to filter data by month year and quarter and the code that does that is: ...
2
votes
0answers
44 views

PHP - Saving inbound email and its attachment

I have below code, which is basically handling inbound emails in my application, save the actual email content (text + attachments) to my database, and further save the actual attachment file on my ...
1
vote
1answer
106 views

Laravel show and update currency from rest api

I need: Daily save new exchange rates from the REST API in the database. Return the current exchange rate for a given currency, the whole table for a given day, the exchange rate for a given currency ...
0
votes
0answers
146 views

Laravel working with dynamic start and end dates to grab some data

So, to start off, the below code does work, but it feels like a newbie solution to me, and if I ever need to come back to this code, I will have no idea what I was thinking. I have a table called <...
1
vote
0answers
71 views

Laravel Controller function to return view based on user permission

I have one route that switches the routes based on the permission the user has. Here is a little example: ...
0
votes
2answers
713 views

Laravel: Export customer record as CSV

Using Laravel, I need to export some value from the DB in a CSV and then upload the CSV via sFTP or return it in a Response. I'm trying to be use S.O.L.I.D. principles but with this scenario, I'm not ...
1
vote
1answer
43 views

Laravel function to add a supplier, and associated addresses and contacts

I have a function addSupplier() that adds a supplier. Each supplier has multiple addresses and each address has multiple contacts. ...
0
votes
1answer
58 views

How I can short my code when request have many parameters

Brief: I've create simple filter in my laravel project. I'll send parameters with ajax request. Code: ...
1
vote
1answer
44 views

Showing data for a chat with another user

I have a get route to show the data for a chat with another user. If an existing chat exists I want to return that, otherwise create a new chat and return it. ...
1
vote
1answer
132 views

Laravel image upload

I'm new to the filesystem from Laravel, but I need an upload script that allows users to upload images to my server. However, i'm concerned about securety, so I thought why not ask for advice, because ...
2
votes
0answers
60 views

Search query to find articles on website with certain tags

I have the following search query to find pages on my website where I'd like to make as much as possible use of existing functionalities to determine relationship names and to hardcore the least as ...
2
votes
0answers
134 views

SQL/PHP Laravel - Looping through records to find relationships

I have two tables in my database, which contains a big list of organisations. They are called orgs_main and orgs_sub. This is ...
2
votes
1answer
331 views

Retrive relation on a polymorphic model

I have a Game model that is "static". Containing game information and such, and users can comment on all games. Games model <...
5
votes
1answer
456 views

File uploads in Laravel - Single and multiple

I have been reading up on file uploads in Laravel, reading through the documentation and looking at best practices. In my application, I have two instances: an upload area for single files, and an ...
2
votes
1answer
54 views

php Laravel - given a certain argument, call different function

I am building a simple calendar with recurring events. CalendarEvent.php id start_date CalendarRecurringPattern.php ...
0
votes
1answer
102 views

Cross-platform MySQL database backup using mysqldump

In a Laravel (PHP framework) project, we implemented a backup feature - backing up user-generated files and database tables. What we've searched so far, the best solution in backing up mysql database ...
3
votes
0answers
1k views

Full text search for multiple words using Laravel and MySQL

I'm using Laravel 5.6 and MySQL. I need to search multiple columns for a single word or multiple words (e.g., "camhandle", "cam handle"). The way I was originally doing it was just using ...
4
votes
1answer
199 views

Laravel UserController Design

...
4
votes
1answer
84 views

Users adding each other in Laravel

I'm looking for a code review for the following system that I created. It allows a landlord, to add a tenant to start a tenancy. It has added, accept, reject, and prohibits a tenant from adding ...