Laravel is an open-source PHP web development framework created by Taylor Otwell. Laravel helps you create applications using simple, expressive syntax.
3
votes
1answer
59 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
27 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
0answers
62 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
41 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
94 views
Laravel 5 Search
I think I could improve this code a lot, especially this part:
if($month !== "") {
AppointmentsController:
...
1
vote
0answers
43 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
64 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
100 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
337 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
78 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
109 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
50 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
122 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
42 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
36 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
156 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
45 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
117 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
180 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
58 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
55 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
108 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
380 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
81 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
260 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
62 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
135 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
376 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 ...
0
votes
0answers
62 views
My Users Controller
I was hoping someone could take a look at my users controller and give their feedback based one their opinions of what they think of my user's controller. As well as maybe give some ideas if any for ...
1
vote
1answer
182 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
189 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
77 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
331 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
178 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
411 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
266 views
UnitTesting: Is this TestCase overkill?
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
125 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 ...
1
vote
1answer
56 views
Object instantiation with multiple parameters
I'm trying to create a little block presenter for Laravel which displays blocks of content in certain positions. I have 2 classes, BlockFactory and ...
2
votes
1answer
474 views
Laravel controller for form validation skinny
I'm trying to make controllers skinny as possible. I use repositories for accessing the database and I use Services to do other stuff. In this case, I use it to insert a new post to the database. For ...
2
votes
0answers
190 views
Immediately send redirect response, preserving session data
This question is for Laravel 4 only, as the relevant parts are completely refactored in the upcoming Laravel 5.
I have written an helper function for validation, so I only have to put this in ...
1
vote
1answer
792 views
Product page filter
I am still learning Laravel and I am in the process of creating a small shopping website.
On the left hand side there are a series of filters that appear depending on what products have come back ...
1
vote
0answers
98 views
Script that receives and formats data
The code snippet below, receives data from a form, formats and inserts into the database.
This code snippet is located in a controller and the insertion is done in a '...
3
votes
0answers
340 views
Laravel Testing: Is this testing too much of the inner workings?
So I'm using laravel for a project and have a InvoiceRepository and a InvoiceRepositoryTest and I have written the test first ...
1
vote
1answer
388 views
CRUD implementation using Laravel 4
I just started using Laravel 4. I read some tutorials on how to implement CRUD in Laravel, and I was able to develop a portion of it. What I am going to show you is more on Controller and Eloquent ...
1
vote
0answers
227 views
Laravel Pagination: a new one adapted from an old Dreamweaver extension
I'm new to Laravel and I'm trying to port the most important old-procedural-code snippets and libraries I collect in some years
I missed a nice Pagination I had in an old Dreamweaver extension and I ...
3
votes
2answers
379 views
Effective usage of multiple joins in Eloquent dependent on variable
I have an Eloquent model that has multiple types of joins that is used to filter out different request to grab the data of movies e.g.: Actors, ...
4
votes
1answer
82 views
Returning JSON depending on the route_id
I have a controller that has a purpose of returning json depending on the route_id being passed from the route (Using laravel). There's a point in my code where I ...
4
votes
3answers
3k views
Controller method - Ajax request
I'm quite new to Laravel, and I'm not sure what am I doing is the best practice.
I'd like to return JSON if the request is Ajax, or return a view otherwise. This is the way I made it, and it works ...