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

2
votes
1answer
18 views

Database query with Eloquent

I have got two tables articles and tags in the database. My goal was to retrieve all fields from articles table and one category field from tags table with Eloquent. I couldn't do this so instead I ...
1
vote
0answers
44 views
+50

Basic CRUD in Laravel 5.2.37

Controller class ...
0
votes
2answers
59 views

Logging in with multiple types of info

I'm trying to let users log in with multiple columns (e.g. ID, email, phone). If one fails, it checks the next column. I would like to minimise my if and ...
0
votes
0answers
28 views

Laravel dropdown list without empty values

I'm creating dropdown list from all possible cities in database, all cities are distincted. ...
0
votes
0answers
33 views

Laravel transactions with a database

I'm really concerned about my transaction with a database and my code structure. I have created more methods to insert, update, delete data to the database but sometimes some of them will break or ...
0
votes
0answers
31 views

Responsibilities in discount method on controller - Cart service

This method is accessed when the route cart/discount/hash_code_discount is fired. Basically, I have a cart in my session and by this method I need to recalculate ...
1
vote
0answers
53 views

A Search Engine Class

I've built a Search Engine class for a website that permits to search companies in base of their locations and their categories (companies pay a plan to be found in the places that they will). In the ...
1
vote
1answer
66 views

How to optimize Method Visibility and code structures for better performance?

I'm creating an application to get data cross domain all the line of code seem work as well but I'm not much understand about performance with my code process with the real server and real action ...
-1
votes
1answer
62 views

Authorizing users for POST requests

I've to authorize some users to do POST requests from their CMSs in order to create a new resource on my database. I've to send a JSON response containing the status of the response (successful or not)...
0
votes
1answer
37 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
123 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
404 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
57 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
177 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
53 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
96 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
44 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
64 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
43 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
80 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? AppointmentsController:...
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
169 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
101 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
49 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
209 views

Laravel 5 Search

I think I could improve this code a lot, especially this part: if($month !== "") { AppointmentsController: ...
1
vote
0answers
106 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
104 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
161 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
403 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
106 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
145 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
62 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
306 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
50 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
46 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
366 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
50 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
205 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
340 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 ...
2
votes
0answers
146 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 solution....
2
votes
1answer
638 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
98 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
359 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
83 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
146 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
502 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
272 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 ...