Questions tagged [laravel]

Laravel is a free, open-source web MVC framework for PHP.

Filter by
Sorted by
Tagged with
1 vote
2 answers
133 views

Placing business logic on a not so small/big project

I am having a bit of problem trying to find the correct place for business logic. The project I am working on isn't huge, but is not small either and has a very considerable importance in my company. ...
Bernardo Benini Fantin's user avatar
2 votes
2 answers
728 views

Is it good design to have a repository update multiple entities?

I'm building a web application using Laravel. I use the repository pattern as my data layer. Imagine there's some entity like Product and a product can be assigned to a ProductCategory. The Product ...
user2190492's user avatar
0 votes
0 answers
58 views

Mapping complex data/arrays to a standard format (normalizing data)

I am currently building an application that receives inbound XML files from a third party system. These XML files represent different types of orders in the sending system. These can for example be: ...
oliverbj's user avatar
0 votes
0 answers
62 views

In Laravel, how do you handle a resource being managed differently depending on a user role while using policies?

I find myself in a situation where I have two roles, "Admin" and a "Organizer". The "Admin" accesses the AdminUserController to update users, while the "Organizer&...
Aridez's user avatar
  • 119
-2 votes
2 answers
56 views

How to serve customized content to each user, based on targeting criteria?

In my PHP Laravel application, I want to display special offers to users, depending on the quality of their house(s). There are 4 Models: User, House, Offer, OfferTargeting. Each User can have many ...
Tim Kohlen's user avatar
1 vote
1 answer
429 views

Validation in both controller and my service classes?

I use the Laravel framework. I've got controllers, like CustomerActivityController, and I've got a service layer with services like CustomerActivityService. Say I want to create a new customer ...
user2190492's user avatar
0 votes
1 answer
183 views

Why doesn't Laravel actively support Service Classes?

There must be a good reason for this. Laravel's default pattern makes no use of Service Classes... but the Laravel community's best practices is for business logic to be stored in them. Laravel's ...
Django Reinhardt's user avatar
7 votes
1 answer
395 views

Service Design Pattern

I'm working with services and I found out there are at least 3 ways to use them inside controllers... Statically: Like helper, Text::uppercase('foo') Instancing it: $text = new Text(); $text->...
JuliSmz's user avatar
  • 181
2 votes
0 answers
64 views

How to back out of a website development job that's way out of my league [duplicate]

TLDR: project scope has crept beyond my capabilities and I need an early exit strategy (in both parties' best interest) Early last year I took on a gig to develop a web application for a financial ...
eric_tet's user avatar
-1 votes
1 answer
79 views

How to write package for two frameworks

I'm developing a package for Laravel & Lumen in the same code base, but I encountered some problems. Well, in the beginning, I thought it could have the same code and work for both frameworks, ...
Ariana's user avatar
  • 17
-3 votes
2 answers
161 views

Does DigitalOcean offer enough resources to run a scalable MySQL cluster?

I have a Kubernetes instance from DigitalOcean that has 2 worker nodes and 1 load balancer. Now I want to create a MySQL managed database cluster for the app that will run on that Kubernetes. Question ...
emma's user avatar
  • 133
2 votes
1 answer
505 views

Is it considered as best practice to use migration scripts for one-off large data manipulation over a table?

I have inherited a project via laravel that uses its database migration mechanism coming from the framework. The application has the following table named actions: action_log_id SERIAL PK user_id INT ...
Dimitrios Desyllas's user avatar
0 votes
1 answer
209 views

Modular code how do they really fit together?

Let's say I am developing an ecommerce application. And I have modules organized in certain way. Products Coupon Tag (can be used as brands and linked data) Offer Now what I want to achieve is user ...
Rajesh Paudel's user avatar
1 vote
0 answers
25 views

Is this kind of polling from backend (Angular + Laravel) acceptable?

I created a forum where I want to display notifications and messages as soon the user gets them. I don't want them to need to refresh to page to see if any notification/message been sent, but I also ...
Giuseppe The Dreamer's user avatar
3 votes
1 answer
542 views

Refactoring a Laravel application layers

My Laravel project starts to grow up and I'm starting to dealing with fat Controllers and Models. Probably I'm for away from the SOLID principles path and my code is not DRY. I decided to refactor my ...
Steve's user avatar
  • 131
2 votes
0 answers
610 views

Is it bad practice to use RAW SQL when Laravel Eloquent offers query building alternatives?

I am new to using PHP Frameworks. I decided to try out Laravel. In my project, I needed to write a search function which will search through a few entities based on some keywords, then do a UNION and ...
John's user avatar
  • 147
-3 votes
1 answer
104 views

Does it make sense to build api and web in one app?

My employer recently learned of Laravel, and has asked us to migrate much of our development to it. None of us have issues with this, as we’ve all played around with it. We have two main in-house ...
Lino Altamirano's user avatar
3 votes
1 answer
653 views

Should I put add() method in Laravel model

It's my first post here as I understand that SO is a platform to find fixes and this is where to ask questions about more general questions. Correct me if I'm wrong I'm working on project in Laravel ...
NoOorZ24's user avatar
0 votes
1 answer
174 views

Should I skip some migrations on production in case of migrating a legacy database that has not been generated via migration script?

I have a complex PostgreSQL database structure that is consisted with views, materialized views and foreign wrappers. The database schema is manually updated without any sort of migration script, ...
Dimitrios Desyllas's user avatar
1 vote
1 answer
250 views

Do authorization checks belong in the controller or the repository/persistor

I have a Laravel project where the controllers (all derived from one of two base controllers) use repository and persistor classes to interface with Eloquent models. Authorization logic is implemented ...
kaan_a's user avatar
  • 155
2 votes
1 answer
646 views

What is the easiest and most flexible to scale method for handling recurring tasks that don't have an end date and will dynamically change?

Problem: I'm writing a service in Laravel 6.2 that will send out a push notification to different users at specified times down to the minute. Users select how many times a month, week, or day and at ...
SaundersB's user avatar
  • 147
0 votes
1 answer
2k views

Complex roles, permissions and hierarchical group management in Laravel

I'm currently in the planning phase / feasability study of a rather big web application which is meant to be implemented using Laravel. My own experience on the matter is rather limited but I'd like ...
Broco's user avatar
  • 81
1 vote
0 answers
124 views

How to setup git repository subfolder mirror?

It is known that Laravel Framework consist of library collection named Illuminate. In which some libraries are mirrored into separate repositories, right under https://github.com/illuminate/ namespace....
Abdillah's user avatar
  • 127
0 votes
1 answer
28 views

Application which checks urls from different locations

I'm building an application which monitors uptime of hosts/ip addresses. I'm using Laravel + VueJS. So the app should check lots of urls every minute and get & store in db http responses. I've ...
Victor's user avatar
  • 111
0 votes
1 answer
181 views

How to access parent relationship in repository pattern

I have two models Permission and Role, now in roles/create, I need to show all the available permissions to allow admin to select the permission and create a role, now should I import both ...
Prafulla Kumar Sahu's user avatar
1 vote
2 answers
100 views

Laravel Controller Testing

This is the first time I tried TDD. At the first time, my controller tests looks like this use RefreshDatabase; class ControllerCustomerIndustryTest extends TestCase { use RefreshDatabase; ...
Christhofer Natalius's user avatar
2 votes
1 answer
154 views

Multitenant setup with master account

I would like to make a SaaS which would be a multitenant system. Development is done in Laravel, which is less important. What I would like to know is how would you handle having a master admin ...
Norgul's user avatar
  • 149
3 votes
2 answers
923 views

Should on each test create and nuke a testing database?

In my case I inherited a poorly engineered code, on that piece of code I have been tasked to increase the code coverage in integration tests. But instead of the usual pattern: Create/Populate a test ...
Dimitrios Desyllas's user avatar
0 votes
0 answers
25 views

Building an API for long distance customers with IOS App, single or multiple calls?

I am in the process of building an API in Laravel and my server is currently stored in the UK. Now I have read some of the posts relating to this topic on Stack but I am still a little unsure as to ...
IconicDigital's user avatar
0 votes
2 answers
2k views

How to avoid duplicate code in two similar MVC controllers

I have two panels, one for the admins and the other for partners. And there are two OrderController with Admin\OrderController and Partner\OrderController namespaces. They both look very similar. ...
Pouneh's user avatar
  • 11
1 vote
1 answer
48 views

modular system (packages) with dependencies?

I am building few sites for my company's client. The sites are mostly the same but could have some customisations. so we decided to create duplicate sites instead of multi-tennant and we decided to ...
shez1983's user avatar
0 votes
1 answer
175 views

Creating and Approving OAuth2 clients using Laravel Passport

As I understand with laravel passport, in order for a third party application to consume my api they need to register their application with mine by creating a client. The passport:client artisan ...
adam78's user avatar
  • 291
2 votes
2 answers
672 views

How to generate an access token using OAuth 2.0 for another app that never expires

I'm using OAuth 2.0 with Laravel (Passport) in order to grant access to my frontend app to the API. Access tokens generated this expires after a while. Now, I have a second app that has to consume ...
Badro Niaimi's user avatar
2 votes
1 answer
355 views

PHP - Dynamically apply parsing rules to text, and save to dynamic fields

OK, so I have been at this problem for the last few days, and I must admit - I am stuck. I am trying to make a web application, where users can upload documents or send inbound e-mails. Each ...
oliverbj's user avatar
1 vote
1 answer
581 views

PHP - Designing a rule based parsing engine

Dynamically apply methods/"rules" to documents I hope someone here can help me/guide me in the right direction. I am currently creating a web application, where users can import a text file, ...
oliverbj's user avatar
1 vote
1 answer
111 views

Data is in database or get from API, where should API request code goes?

For me, the data I want to retrieve may be in database for which I can use properties of model and also relationships, but if the record is not a property and no relationship exists for that ...
Prafulla Kumar Sahu's user avatar
3 votes
0 answers
199 views

How to let users specify their own logical conditions (PHP / Laravel)

I am currently trying to create a web application, that saves inbound emails. I have figured out how to save the incoming emails into my database, and I have all the email information available (...
oliverbj's user avatar
-2 votes
1 answer
51 views

over come HTTP client time out issue

I have an api end point which receives some parameters and process them returns a csv file. But the processing time may take more than 15 seconds. My server has build in timeout and some client ...
Ebin Manuval's user avatar
1 vote
1 answer
2k views

Use same API for both website and other clients or not?

Lets say I am building some large application ( multi-page app ) using Laravel. And laravel will allow me to make an API and a website on the same application. Since the website and the API ...
rook99's user avatar
  • 121
2 votes
2 answers
1k views

Integration Testing: Should a test check every validation?

I am somewhat new to writing tests and I want to build that habit into my workflow. So for example I might write a test that a user can create a blog post however I'm not sure on how to do that ...
St0mX's user avatar
  • 221
-1 votes
1 answer
206 views

Database abstraction layer

I'm currently developing an SaaS application in PHP, with Laravel, using its own DB class. Let's pretend we've got 2 classes under 2 namespaces, plus Laravel's own DB - so Illuminate\Support\Facades\...
XLR's user avatar
  • 11
1 vote
1 answer
539 views

Queuing emails in Laravel when using an api driver such as Mailgun?

In Laravel (for the record I'm using v5.6) there is an option to queue emails for background processing. I have a scheduled job to send out daily email alerts to users. Currently the job drops the ...
adam78's user avatar
  • 291
0 votes
1 answer
563 views

Unit tests involving library functions and objects

I am making a project using the Laravel framework. I plan to create unit tests for my project. But I feel I don't really have an idea what to test because I mostly use library or framework functions. ...
lightning_missile's user avatar
0 votes
1 answer
737 views

Is this a 'proper' use of a trait in PHP?

In Laravel 5.6 an Illuminate\Database\Eloquent\Relations\BelongsTo relation was given the ability to support default models. This allows a model that will be returned if the relationship is empty. ...
flyingL123's user avatar
0 votes
1 answer
156 views

Using the objects retrieved at the time of request validation

I hope the question title already answers the subject here. Lets say I have a number of ids that needs to be validated in a request. Example: request uri: [POST] /album/{album_id}/song Request ...
TheManish's user avatar
1 vote
1 answer
1k views

Best practice API design for mobile app in sending multiple photos in one request?

I'm working on API design for a mobile app where the user can send one or more photos that will be stored in the database. Currently I have three routes, post photo/create which will send one photo ...
Rizki Hadiaturrasyid's user avatar
1 vote
0 answers
845 views

Handling complex dynamic queries in Laravel 5

I am developing a project using Laravel. My workflow is: route directs to controller Controller calls eloquent models Eloquent models perform queries (tipically CRUD and find) Controller returns ...
lightning_missile's user avatar
0 votes
1 answer
121 views

Is Dependency Injection A Standard in PHP and Laravel?

Or in actuality, how to tell if a certain technique has became a standard in certain language / framework? As I understood from my readings so far, PHP supports DI in PSR-11 while Laravel uses it out ...
krubix's user avatar
  • 19
2 votes
2 answers
823 views

Consume own API or make independent website

The PHP framework Laravel allows to make an API and a website on the same application. As both of them will communicate with the same database, I was asking myself what is better between consuming my ...
JacopoStanchi's user avatar
1 vote
0 answers
215 views

Storing laravel API tokens from one API in another APIs env file

Last year my company started using Laravel to build APIs, and we created two separate repositories - one for a primary API and then a second for a secure API that would only accept requests from the ...
Sam Onela's user avatar
  • 117