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
2
votes
2answers
50 views

How to reduce a POST request duplicate in Laravel/PHP for payment system?

I'm using PHP/Laravel and I have two controllers. Controllers/PaymentController Controllers/PaymentExpressControler They both create an request which is exactly the same, but it has some differences....
4
votes
2answers
312 views

Laravel 8 registration and login with user profiles

I am working on a Laravel application (Github repo) that requires user registration and login. Alter registration, the users can change their registration details (except password, for which there is ...
3
votes
0answers
38 views

class uploade file(photo,video,..) laravel

I am working on a project, the previous programmer used this method to save photos, videos, etc. ...
1
vote
2answers
140 views

Laravel controller method to update user

I'm using Laravel and this PHP method is in a controller. It's the back-end for a edit profile page. The user can change the profile picture, reset the password, the username, and so on. I'm new in ...
4
votes
1answer
44 views

Single end point REST API

I want to ask question about a better way for implementing single endpoint REST. I want to build a rest API but I want it to only have single endpoint like: graphql,...
2
votes
0answers
62 views

Is it okay to use interfaces on tests?

I have created a test, also the interfaces to be implemented for each test case based on user's role because I think it would make it easier to understand what the test case will and should do, also ...
3
votes
0answers
41 views

Add pivot data from the same pivot model [closed]

My project has thee models Cart, Order and Product Cart ...
6
votes
2answers
179 views

Queries to get unpaid and unpaid invoices

Here is my code: ...
2
votes
1answer
68 views

Route Improvement in Laravel 8

I have below route. I am using Laravel 8. ...
3
votes
1answer
54 views

Get all routes that start with rt_

The code reads all my routes and return to my AJAX request the names of the routes without duplicates and just those that have the "rt_" prefix. ...
1
vote
1answer
216 views

Improvements on Laravel's base Model and FormRequest

Introduction I've improved, IMO, Laravel's base Model and FormRequest. It's working as expected. But, before actually implementing this any further in my application, i want to have my classes checked ...
2
votes
1answer
56 views

PHP Laravel Order generation Custom Class

Here is a custom class I use to handle different types of orders in Laravel. This question includes the code regarding Order Type A. I want to know whether I can simplify the code. I have different ...
3
votes
0answers
63 views

API Client and usage implementation

I'm really bothered with my approach in this, as I'd like to use the client in multiple projects. The client is just extending Guzzle and I'm using a factory method to initialize the client with the ...
1
vote
2answers
105 views

Displaying filtered user data using Ajax and PHP

I want to get my code cleaner and more efficient. This code gets variables form a PHP file and filters it to show the selected user name, all available usergroups on a list box and the groups he is ...
2
votes
2answers
123 views

Structuring code logic for events on laravel controller

The code below will store a base64 image on another website and create an event to display the image on a Vue page in real time. It works fine and all. My question is, is this a good way of doing it ...
4
votes
2answers
68 views

Filtering from a file to show information

I want to get my code cleanner and more efficient. This code gets variables form a PHP file and filters it to show the selected user name, all available usergroups on a list box and the groups he is ...
3
votes
1answer
179 views

Does PDO::quote helps me to protect me against sql injection?

I have to process raw sql user input with Laravel. I've backed them up as follows: ...
5
votes
2answers
447 views

Implementing Laravel old data in Vuejs

Users input their pin-code which is checked against the database and returned with the locality, district and state associated with that pin-code. Multiple localities may be returned so the options ...
1
vote
0answers
41 views

Booking system ala airbnb many to many laravel relationship? [closed]

I'm trying to create a system to log all bookings for a few airbnb hosts, at first I had two models Home and Guest, where a home can have many guests and a guest could book for many homes, then I ...
2
votes
1answer
83 views

Using method trait to return something in laravel model

I have question about scope yesterday, and someone gives an answer to don't return anything in scope. Is return something in scope really bad practice? Should I not return anything in the model ...
1
vote
1answer
58 views

Handling multiple try-catches in a for loop

Good day! I would like to know if this is possible to be refactored into a cleaner code. The reason I'm doing it like this is to catch the column that the error appeared on and then potentially output ...
5
votes
1answer
395 views

Laravel Scope get request data/param

I want to pass the param from the request on the scope method in the model and serve it as json to be rendered by select2. Which is better? 1. Pass request from the controller like this controller: <...
4
votes
1answer
48 views

Protecting Vue page based on the API response

If the user/visitor has access to the API route, then the status code will 200, else 401. I know that I can user Vue navigation guards, but I will need to use Vuex. This way is much simpler and faster,...
2
votes
1answer
68 views

Controller in Laravel with parsing, creation and relationships

The following code represents the store method of a resource controller. A user can create an training offer on my website and can pass various information like ...
-2
votes
1answer
59 views

Laravel Page Controller [closed]

Aim: To make pages located in site.com/page-1, site.com/page-2. Those pages are pretty much static so I won't use database. First, I've created the PageController. ...
3
votes
1answer
66 views

Filtering multiple request parameters

This is pretty straightforward, it takes requests from the frontend, checking if it is present on the request, if it does, an action is taken for that if statement. I wonder if there is a way to ...
1
vote
1answer
69 views

What would be the best way to update data from associative array?

I recieve this array in my controller: ...
1
vote
1answer
48 views

Importing data from spreadsheet

Not really an issue I am stuck on (the code works) but I just really don't like some code I wrote, if you're bored in lockdown maybe you might like to help. Context: I am import some data from a ...
0
votes
1answer
55 views

PHP - Importing columns from uploaded CSV file to SQL database (Laravel 5.7) [closed]

The goal is to upload the columns from the csv into the SQL Pro database. I am able to select the column names that have been uploaded from the csv file, the columns from the csv file are then ...
2
votes
1answer
100 views

Create user in users table and insert data into second table with one form in Laravel Relationships

I'm trying to create a user while adding data to a second table via one form: users table: ...
2
votes
1answer
106 views

Get list and default value of columns of table with Eloquent

I use the below code to get a list of columns in a table, and assign the default value to the protected var $attributes in a Laravel Model. In this code, I use the DB function because I don't know ...
2
votes
1answer
81 views

Refactor PHP | Laravel Code, Optimisation needed to make code clean

I have made some notification preferences in which there are 4 major preferences SMS PUSH FAX EMAIL And then there are some specific templates such as ...
1
vote
3answers
259 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
132 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
222 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
1answer
489 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
109 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 ...
1
vote
1answer
373 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? ...
3
votes
2answers
72 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 ...
2
votes
0answers
66 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
143 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 ...
1
vote
0answers
32 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
122 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
27 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
44 views

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

I have these scripts ...
3
votes
0answers
84 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
38 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
44 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
34 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
2 3 4 5