Csrf token issue with scaling

I have scaled my application to 3 different servers that use common mysql and redis service. Than I have set session and cache driver to my redis (they are working fine). But I still get token mismatch error. Did anyone solve this problem without tur...
more »

2017-10-04 16:10 (1) Answers

check or condition in where clause

I want to check OR condition for the variable role_id in role_mapping table. I want to check if user_id has role_id either '2' or '3'. User with user_id=210 has role_id 2 and 1. but my query result prints '3'. How to use or condition in Laravel query...
more »

2017-10-04 14:10 (1) Answers

Don't show empty parent category in Laravel

I have parent and child categories on the page. What I'm trying to do is when there is no products and no sub-categories assigned in some parent category to not be shown on the page. So I have this in Category model public function item() { re...
more »

2017-10-04 14:10 (1) Answers

Laravel use a custom validation message

I have made a custom rule in Laravel 5.5, but also want to get a custom translation with it from the lang validation file. For that I have now done: 'custom' => [ 'validate' => [ 'correct_password' => 'The :attribute is incorrec...
more »

2017-10-04 12:10 (1) Answers

Laravel collection filter by condition and split

I have a collection and each item has a featured attribute which is either true or false, so I want to get two variables $featured and $unfeatured. I can do this: $featured = $collection.filter(function($item){ return $item->featured; }); $u...
more »

2017-10-04 03:10 (2) Answers

mocking hasMany relation in laravel 5.1 unit test

For a unit test in laravel 5.1 I am trying to test a cascading delete function of the Client model, which, with the recursive flag set, should also delete all users associated with the client. I want to use a mock user adn test only wether the delet...
more »

2017-10-03 17:10 (0) Answers

Laravel SOLID using Repository Pattern

I want (at this moment tyring) to follow the SOLID principles, but my mind is going to blows up. I read a lot of posts about Repository Pattern in Laravel to follow the SOLID principles. My question is very similar to this question. But I don't unde...
more »

2017-10-03 14:10 (2) Answers

Laravel form array validation

I need some help for validating my form with Laravel 5.4. My form: {{Form::bsText('general[firstname]')}} {{Form::bsText('general[lastname]')}} Then I have a RequestObject for the validation with the following rules: 'general[firstname]' =>...
more »

2017-10-03 11:10 (5) Answers

Item date sorting from API JSON in angular

I've generated some news items from a laravel API output, i display these on a angular 4 cli project. I noticed the items aren't on descending order though and I'm trying to fix this on the client side. Check it out, this is what I've got. This is m...
more »

2017-10-03 11:10 (4) Answers

How to configure Laravel on remote server

I'm new on Laravel. Installed laravel on my remote server ubuntu14.04. I create a project on /www/html as blog. Then run php artisan serve --host=10.x.x.12 --port=8010. #Laravel development server started: <http://10.x.x.12:8010> Its ok . I ...
more »

2017-10-03 11:10 (1) Answers

Laravel blade assign css class conditionally

I would like to add a css class condionally in my blade body tag by adding auth-container class if url is either /login or /auth/reset-password so i have <body> //here add class So i have tried @if(in_array( , ['login','/auth/reset-passw...
more »

2017-10-02 20:10 (1) Answers

Try and Catch laravel it's not working for me

i've a little problem, I'm trying to add the validations (Try and Catch) on my laravel project, the problem is that in some controllers works fine, but in a specific doesn't work, the validation is when try to load a page, and something went wrong, t...
more »

2017-10-02 20:10 (1) Answers

S3 URL directly in Model

I am using S3 to save the images of my web-tool. At the moment I am saving the key ('images/x/y.jpg') to the database. To get the URL of the file I am doing this: Store::cloud()->url(key) Is it possible, to do this step to convert the key to a...
more »

2017-10-02 19:10 (1) Answers

Carbon unexpected date-time format in Laravel

I have problem with Carbon and HTML5 input input[type=datetime-local] because this input sends datatime in format Y-m-d\TH:i (eg. 2016-11-20T11:45). I have method in my controller: public function store(ModelStoreFormRequest $request) { $mode...
more »

2017-10-02 16:10 (1) Answers

Avoid "auto login" when password is reset

I am working on a Laravel project. I was not the original developer, so if I make a mistake, forgive me and explain what it was please. In this project, we have a module to request a new password. when the form is submited, the user is redirected to...
more »

2017-10-02 13:10 (1) Answers

Laravel Blade Using custom function

I have a blade where I'm printing the content of a table. For some columns I need to add the CSS class according the value I'm printing. E.g. if it's "OK", add class Green, otherwise class red. Of course the logic will be more complex, but the point...
more »

2017-10-02 13:10 (2) Answers

Belongs to pivot table in Laravel 5

Let's say I'm having the following database schema: dogs and owners are connected with classic belongsToMany. How about the walks table? I'd like to be able to use Eloquent goodies in such kind of relationship: $dogs = Dog::with('walks')->get(...
more »

2017-10-02 12:10 (1) Answers