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

learn more… | top users | synonyms

0
votes
1answer
31 views

Repeating HTML, minus a few class and array key differences

I feel like this code is pretty sloppy and can be accomplished in a foreach loop. But it's a bit complex using a multi-dimensional array. Can this be cleaner? You ...
3
votes
1answer
75 views

Accessing Data inside Presentation Layer from API: Laravel 5.2.27

I wrote the code to fetch the JSON Data. For that I tried to do this in 2 projects. First Laravel project which has API code for database interaction only. Sample code in API controller ...
2
votes
1answer
125 views

Profile picture upload method in Laravel 5.2

I am a Laravel newbie so please forgive me for my code... I have a method, in a Laravel controller, that updates the current logged user profile (...
0
votes
0answers
37 views

Dynamic reports to Laravel view into HTML table

The getDynamicTeacherCount function is generating number-based reports from the table that I have in database and the ...
0
votes
1answer
60 views

Laravel bulk insert optimization

I'm currently using a make shift INSERT on DUPLICATE UPDATE function that relies on a DB raw query from eloquent. I'm looking to improve the quality of the code and the speed. Please take a look ...
4
votes
1answer
46 views

Generating statistical reports

I want to generate statistical reports and I have many different where clauses so the function became long. I did much refactoring, but it is not enough. Can ...
3
votes
1answer
59 views

Eloquent methods to calculate the average rent of apartments

I am working on a Laravel 5.1 website where I am counting the average rent of apartments in a specific area. Besides of that I want to get the average rent by amount of rooms in the apartment. The ...
1
vote
0answers
34 views

Proper PHP array walkthrough

I am working on a ticket reserving system right now. The users can reserve seats in a cinema for every movie. Whilst my code works, it is not the fastest. When a customer buys ticket (seat(s)) I check ...
1
vote
1answer
61 views

Method on Laravel model to find courses related to a course

I have a Laravel project that has courses. I want to take the related courses from one. Should I create the method in the model (the php class) or in the controller? Currently I have this code in ...
1
vote
0answers
39 views

Use of HTML (view) in a constructor

I have this constructor (from a Service) where I'm setting a few variables, but two of them include HTML. Is there a best way to set those values, maybe by creating a method in the class to set them? ...
0
votes
1answer
59 views

Laravel 5 controller to list appointments by date range and by label

I am starting to get into OOP using PHP and MVC. I just want to know if this code is good practice. Is this how I should be using my controller and model, in its simplest form? ...
0
votes
1answer
44 views

Compare 2 Different database Table

I have php function that compares two different database table. Any suggestion on improving it. ...
4
votes
1answer
139 views

4 database queries, multiple loops in loops, slow processing time

The octoberCMS(based on laravel) controller below is what I use to select the lowest price in 4 pricelists in the given daterange. Prices can vary and it's not guaranteed that the more expensive ...
1
vote
1answer
31 views

Calculating a quality score of something based on attributes

I'm willing to have a way to calculate a quality score of an object; in this case an addressbook contact. I believe there are way better approaches to do this and I'd like to hear your references. ...
2
votes
1answer
86 views

Class that generates records after performing business logic

I wrote a small class that does a database lookup and it generates a collection/Array. The Collection is resorted based on values returned from the database. Finally, the records can be retrieved ...
1
vote
1answer
48 views

Handle data insertion after validation

I have an application that has a form. Validation and data insertion works fine. However, it bulks out my controller. I've always been told skinny controllers. For example: ...
0
votes
0answers
167 views

Laravel 5 Search

I think I could improve this code a lot, especially this part: if($month !== "") { AppointmentsController: ...
1
vote
0answers
90 views

Extended Laravel Eloquent models to add filters to model setters

One of the tasks I find myself doing repeatedly is to filter the incoming inputs that will be stored in models. Examples of this include trimming, removing repeated or unnecessary pre/suffixes, commas ...
1
vote
1answer
95 views

Resumé builder app

Wrote this an hour or so after learning some basics. Took me a while because I had to write it in a way to fit the previous structure of my page. Basically, there are three rows of data. There has to ...
2
votes
1answer
139 views

Laravel API design

I've been designing and coding my Laravel API boilerplate for couple days now, and I'd like to hear some advice/improvement hints! I'm pretty satisfied with the result, but I'm also aware, there ...
3
votes
1answer
389 views

eCommerce project using the Repository pattern

I am currently working on an eCommerce project in Laravel 5.1. I have implemented Repository Pattern by learning from this site only for 1 model, namely, ...
4
votes
2answers
96 views

Insert and attach tag to the post in same time

I created a form with title, body and tag input and there are 3 tables: posts, tags and post_tag. Now I use this function to add new tags and attach them to the post postcontroller.php ...
0
votes
1answer
133 views

Laravel API class design

I am building my first Laravel web app and I have created a class to handle API requests for a model called Quote. In what ways can the code be improved or reduced? ...
0
votes
1answer
56 views

Basic sign-up method, testable and with try/catch [closed]

I am learning how to implement testing and try/catch statements into my code. I have a Laravel application with the following ...
1
vote
1answer
254 views

Laravel controller for a grocery list

What I have is a grocery list. Once I select a grocery by ticking the checkbox, I can select an amount for that product and a unit (unit is referred to in my below code as group). Once I am done, I ...
3
votes
1answer
49 views

Exception Handler on a Switch

I am working on rewriting an application in Laravel 5.1. I am new to the exception handling technique introduced in 5.0. I have overlooked taking advantage of throwing/catching exceptions frequently ...
1
vote
1answer
45 views

Selecting orders submitted by a user, segregated by status

I have recently started using Laravel as my chosen framework. It is my first time using a framework. As I have made progress through my project, my controller methods have started to increase in size. ...
0
votes
1answer
240 views

Laravel Controller including sort and search

I am using this code on my own personal website (my personal administration site) so it doesn't need any security and so on. I am not into learning everything about that yet, and although I do know a ...
2
votes
1answer
47 views

The correct place to implode array - MVC and Repositories concept

I am writing an application with the repositories concept in php with laravel framework. In my controller I have this method: ...
1
vote
1answer
180 views

Laravel user permission system

I wanted to create a simple and easy to use permissions system. The ones I've found on the Internet would need to attach every permission to a route manually (e.g. Entrust). My idea is to build a ...
1
vote
2answers
289 views

Multi-User Roles in Laravel

I am very new to Laravel. I am building a website where multiple users can have one or more roles. I have a users table and a user_roles table. Each ...
2
votes
1answer
59 views

Collection of $_POST data

I have a backend API that I'm sure can a refactor, but I'm not exactly sure how to avoid repetition between the store method and the ...
0
votes
0answers
74 views

Dynamic/Global Business Days Calculation

I have a problem in that I need a formula which calculates business days around the world. For example, in the UK we have 5 day weeks, but in the Middle East they have 6 day weeks. Also, perhaps we ...
2
votes
0answers
129 views

Passing standard data through serviceprovider

I am using Laravel 5. To pass the users his favorites and permalink, I edited the AppServiceProvider. I was wondering if my solution is the most reasonable ...
2
votes
1answer
587 views

Laravel 4 search function

I am using this code in my controller and would like to know if this is good code to use or if I can write it better, or more compact, and so on. I am just trying to learn from this. It does work, so ...
1
vote
1answer
95 views

eCommerce web appliation

I am making an eCommerce web application using the Laravel 5 framework. I have created a Categories controller for the administrator and with the following actions ...
3
votes
1answer
342 views

URL link SEO and security using Laravel

I'm trying to figure out what the best way to do this is. I have a part on my website where people can search for a particular card based on multiple different factors. Like the name of the card, ...
1
vote
1answer
78 views

Laravel time-punching database structure

I am trying to build a database structure for a time punching system. What I'm trying to figure out is if what I have is the ideal structure, or if something else exists that I'm overlooking. I want ...
5
votes
1answer
143 views

Controller to manage athletes

I would appreciate if you could give me some advice about the code below. I am a student learning PHP programming and programming fundamentals. I have learned a lot from Stack Overflow but there are ...
6
votes
2answers
463 views

Routing for a Laravel 5 e-commerce site

I am new here and learning Laravel 5 on my own. I want to get reviewed on the following routes.php code. My question are: Have I made any mistakes by doing this? If yes, then what could be the ...
1
vote
1answer
252 views

Laravel photo uploader class

I'm trying to separate logic from the controller, so I created this Upload class. It is not a big class, just a class so that the controller doesn't know about the ...
1
vote
0answers
231 views

Image upload handling in Laravel

I'm trying to create a handler to set the profile picture for the user. Don't worry about the validation as I will clean that up, because that's for testing purposes. This is how far I went. I'm using ...
1
vote
0answers
108 views

Decoupling payment classes

I have several classes for payment handling, I separate these classes into directories like below. Actually I'm going to use it for Laravel project but to make it simple, maybe we can talk as if it's ...
3
votes
0answers
433 views

Laravel controller for a commenting system

Can someone review my Controller? I should follow these guidelines: Code should be written with MVC pattern and to use OOP. The code now works fine, but I need to improve it. Also, should I use ...
1
vote
0answers
201 views

Laravel routes.php optimization

My goals are: Have 2 main domains .com and .dev for production and local installations Have 2 main subdomains. One for the site and one of the application Site must be public and application always ...
2
votes
0answers
2k views

Laravel 5 Dependency Injecting a Repository into a controller, and depedency injecting an entity into repository

Overview:: I have a Restful API that pushes all /api/{version}/{Repository} into my ResourceV{1}Controller depending on the ...
3
votes
1answer
37 views

Formatting database results to be consumed as multiple tables by the view

In the code below, $rows is the result of database query. In the view that consumes this, I need to break the results into a separate table for each vendor. The below creates a structure that allows ...
2
votes
1answer
420 views

Controller for repository of members

I tried to implement the Repository pattern for my project: MemberController.php -- this one is a bit too long and has repetitive code ...
2
votes
1answer
347 views

Unit tests for a Laravel site

Is this Test Case overkill? I am new to Unit Testing so I am learning and I'd love to hear your opinion about it. ...
3
votes
0answers
151 views

Instagram-like news feed display

I am writing an application that shows a news feed, much like Instagram. For this, I have a function in the model to select the feeds as shown in the code. For some reason, this runs quite slow and I ...