leandromatos

leandromatos

Member Since 3 Years Ago

Belo Horizonte, MG

Senior Marketing Developer at Hotmart

Experience Points 153,510
Experience Level 31

1,490 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed 1483
Lessons
Completed
Best Reply Awards 8
Best Reply
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • Chatty Cathy Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

19 May
3 hours ago

leandromatos left a reply on Redirect Back With Error Not Setting The Key

Hey man, i tried here and error directive works without problem. When i submit the form, the store method on controller returns the expected message!

In my routes file

Route::get('/', '[email protected]');
Route::post('/store', '[email protected]');

In my SomeController

<?php

namespace App\Http\Controllers;

use Illuminate\Support\Facades\Redirect;

class SomeController extends Controller
{
    public function index()
    {
        return view('index');
    }

    public function store()
    {
        return Redirect::back()->withErrors(['insufficient' => 'You do not have enough coins to proceed']);
    }
}

In my index view

<form method="POST" action="/store">
        @csrf

        @error('insufficient')
            {{ $message }}
        @enderror

        <input type="submit" value="Submit">
 </form>
18 May
1 day ago

leandromatos left a reply on Redirect Back With Error Not Setting The Key

@ZFDEVELOPER - If im not wrong, the blade error directive was only work with session of the validation data.

Check it out https://laravel.com/docs/5.8/blade#validation-errors

leandromatos left a reply on Redirect Back With Error Not Setting The Key

@ZFDEVELOPER - if you give a dump in the error variable, what does it show?

leandromatos left a reply on Redirect Back With Error Not Setting The Key

@ZFDEVELOPER - What the return content of error variable?

leandromatos left a reply on Redirect Back With Error Not Setting The Key

Try

return Redirect::back()->withErrors(['insufficient' => 'You do not have enough coins to proceed']);
and inside your view call this
@if($errors->any())
    {{$errors->first()}}
@endif

leandromatos left a reply on Different Output Files With Different Configs

Anyway, you can read the any variables in your .env, you only need put this line top of your mix file. This is the other approach.

‘’’ require('dotenv').config(); ‘’’

leandromatos left a reply on Different Output Files With Different Configs

How is your scripts was declared in package.json?

leandromatos left a reply on Best Practice: When To Use A Repository.

This situations is very normal. I think you can use services with repositories. In the services you can make requests for the both exrernal api’s and manipulate all data, in the repositories you can interact with your database.

leandromatos left a reply on User Has Coins And Can Subscribe To Plans

Hum, it’s true.

In this case you can get the coins amount value directly of the Plans model inside the controller.

In the controller:

// fake slugs of plans
$plan1 = $request->has('plan1') ? Plan::where('slug', 'plan1')->first()->amount : 0;
$plan2 = $request->has('plan2') ? Plan::where('slug', 'plan2')->first()->amount : 0;
$plan3 = $request->has('plan3') ? Plan::where('slug', 'plan3')->first()->amount : 0;
$plan4 = $request->has('plan4') ? Plan::where('slug', 'plan4')->first()->amount : 0;

$requiredCoins = collect([$plan1, $plan2, $plan3, $plan4])->sum(); 

if($requiredCoins < $userCoins) {
    // the coins of user is smaller of the sum of the plans selected
}

leandromatos left a reply on User Has Coins And Can Subscribe To Plans

@ZFDEVELOPER - Would not it be more interesting for you to add the amount of coins needed for the plan in input value?

leandromatos left a reply on User Has Coins And Can Subscribe To Plans

Um, of course.

You can sum the selected plans, even if they come in separate inputs.

$master = $request->has('master') ? $request->input('master') : 0;
$exclusive = $request->has('exclusive') ? $request->input('exclusive') : 0;
$advanced = $request->has('advanced') ? $request->input('advanced') : 0;

$requiredCoins = collect([$master, $exclusive, $advanced])->sum(); 

if($requiredCoins < $userCoins) {
    // the coins of user is smaller of the sum of the plans selected
}

leandromatos left a reply on User Has Coins And Can Subscribe To Plans

First you need to add up all the values of the selected planes. Maybe the collection sum method can help you. https://laravel.com/docs/5.8/collections#method-sum.

After sum all the values in the selection request, you can compare.

User coins are less than the sum of coins of selected plans

Maybe like this:

$requiredCoins = collect($request->input('plans'))->sum(); 

if($requiredCoins < $userCoins) {
    // the coins of user is smaller of the sum of the plans selected
}
29 Nov
5 months ago

leandromatos started a new conversation Pause Between Jobs In The Queue

Hello everyone, everything good?

I need to put a job in the queue that will run 2K times. However, I need to pause between each request (something between 5 and 10 seconds).

Basically, I am consuming an API that returns me the data and a key to the next page, however, I have a low rate limit, so I need to pause to consume the data on the next page.

Since each job in the queue would be a requisition for the API, how would you do to pause between the firing of each new job? I'm not sure how to pause between requests.

Thanks

25 Nov
5 months ago

leandromatos left a reply on Different Seeds According To The Environment

Thank you! I had forgotten the possibility of using .env ;)

leandromatos started a new conversation Different Seeds According To The Environment

Is there a way to pass a parameter to the DatabaseSeeder file so it can make a call to a specific group of classes?

What I would like to do is separate class groups from their local development, staging, and production databases, which should have their tables populated differently.

01 Sep
8 months ago

leandromatos left a reply on How To Change Number Of Pages Appear On Pagination Slide?

Thanks for sharing your model @jlrdw.

I mixed the default pagination and the new option of slide pagination on Laravel 5.7 that @Cronix sharing with us.

Maybe it will serve as a model for someone else who needs it.

@if ($paginator->hasPages())
    <ul class="pagination__items" role="navigation">
        {{-- Previous Page Link --}}
        @if ($paginator->onFirstPage())
            <li class="pagination__item pagination__item--disabled" aria-disabled="true" aria-label="@lang('pagination.previous')">
                <span aria-hidden="true">
                    &lsaquo;
                </span>
            </li>
        @else
            <li class="pagination__item">
                <a href="{{ $paginator->previousPageUrl() }}" rel="prev" aria-label="@lang('pagination.previous')">
                    <span>
                        &lsaquo;
                    </span>
                </a>
            </li>
        @endif

        {{-- Pagination Elements --}}
        @php
        $linksOnEachSlide     = 5; // Must be an odd number
        $halfLinksOnEachSlide = ($linksOnEachSlide - 1) / 2;
        $startPage            = $paginator->currentPage() - $halfLinksOnEachSlide < 1 ? 1 : ($paginator->currentPage() - $halfLinksOnEachSlide);
        $endPage              = ($paginator->currentPage() + $halfLinksOnEachSlide) > $paginator->lastPage() ? $paginator->lastPage() : ($paginator->currentPage() + $halfLinksOnEachSlide);
        $endPage              = $endPage < $linksOnEachSlide ? $linksOnEachSlide : $endPage;
        $startPage            = $endPage - $linksOnEachSlide < $startPage ? $endPage - ($halfLinksOnEachSlide * 2) : $startPage;
        @endphp

        @foreach(range($startPage, $endPage) as $page)
            @if ($page == $paginator->currentPage())
                <li class="pagination__item pagination__item--active" aria-current="page">
                    <span>
                        {{ $page }}
                    </span>
                </li>
            @else
                <li class="pagination__item">
                    <a href="{{ $paginator->url($page) }}">
                        <span>
                            {{ $page }}
                        </span>
                    </a>
                </li>
            @endif
        @endforeach

        {{-- Next Page Link --}}
        @if ($paginator->hasMorePages())
            <li class="pagination__item">
                <a href="{{ $paginator->nextPageUrl() }}" rel="next" aria-label="@lang('pagination.next')">
                    <span>
                        &rsaquo;
                    </span>
                </a>
            </li>
        @else
            <li class="pagination__item pagination__item--disabled" aria-disabled="true" aria-label="@lang('pagination.next')">
                <span aria-hidden="true">
                    &rsaquo;
                </span>
            </li>
        @endif
    </ul>
@endif

leandromatos left a reply on How To Change Number Of Pages Appear On Pagination Slide?

This option of Laravel 5.7 is Very nice @cronix. Thanks for sharing.

leandromatos started a new conversation How To Change Number Of Pages Appear On Pagination Slide?

The default pagination of Laravel 5.6 has 8 items before three dots (...) and 2 after.

How to change this size of 8 items? The pagination element too large in mobile viewport.

30 Jul
9 months ago

leandromatos started a new conversation Best Approach For Call Queue Worker With Limits

Hello guys.

I need to call a queue worker that extracts data from an external api (to be more specific, it is the api of Instagram). This api has a limit of 200 calls per hour.

What is the best way to run this worker by pausing for not to extrapolate 200 calls per hour?

07 Jun
11 months ago

leandromatos started a new conversation Share Content With Component That Lives In The Parent

Can I share content with another component that lives in the parent?

An example, I want to open a modal that lives at the root of the application, but calling it from within another component, which in this case, is a child of the application.

Maybe by example it will be easier to understand what I want to do.

app.vue

    <content-1></content-1>
    <content-2></content-2>
    <modal></modal>
</app>```


content-1.vue
```<template>
    <button>Toggle Modal</button>
    <modal>
        <!-- modal content that will be "injected" into the modal that lives in app.vue -->
    </modal>
</template>```

content-2.vue
```<template>
    <button>Toggle Modal</button>
    <modal>
        <!-- modal content that will be "injected" into the modal that lives in app.vue -->
    </modal>
</template>```
02 Apr
1 year ago

leandromatos left a reply on Manage The Costs Of Projects (Digital Ocean + Forge + Envoyer)

@Cronix, This site is an application without SEO, i don't need indexing in Google or others sites.

leandromatos left a reply on Manage The Costs Of Projects (Digital Ocean + Forge + Envoyer)

My projects use a lot of features that are much easier to manage with Forge and Envoyer, wokers, queues ... My stack is very well structured with Digital Ocean, swapping would not be an option, even because Forge does not configure a server on Heroku =(

leandromatos started a new conversation Manage The Costs Of Projects (Digital Ocean + Forge + Envoyer)

Good afternoon people.

I have 2 projects in Digital Ocean (configured also in Forge and Envoyer) that seasonally need to be on the air, something between 2 to 3 times a year.

What would be the best way to manage the costs of this project? I would like to let it out of the air for not having expenses, but at the same time did not want to have to configure the servers from scratch every time I need them in the air.

I even read about Digital Ocean snapshots but I can not figure out how they work for sure. Can someone help me?

Thank you

25 Feb
1 year ago

leandromatos left a reply on Http Error 500 In Fresh Install Of Laravel 5.6

I removed vagrant box and add again. Now works again!

leandromatos left a reply on Http Error 500 In Fresh Install Of Laravel 5.6

I just checked the PHP version inside the vagrant box. It is 7.0.5. Strange, because my homestead is in the most current version.

leandromatos left a reply on Http Error 500 In Fresh Install Of Laravel 5.6

@crnkovic If I add this code to my route file, the error continues to occur. It does not reach the request to show the PHP information.

By terminal I checked and my version of PHP is 7.1.5.

leandromatos started a new conversation Http Error 500 In Fresh Install Of Laravel 5.6

Hello guys, I created a fresh Laravel 5.6 project through composer.

As I use Homestead, I then added it to Homestead.yml and/ etc / hosts, so I up the box with vagrant up. Everything as I usually do, normal.

The problem is that when trying to access a project in the browser I get a http error 500 message.

I checked my log and he contain this message:

[2018-02-25 11:48:50] local.ERROR: Parse error: syntax error, unexpected '?', Expecting variable (T_VARIABLE) {"exception": "[object] (Symfony \ Component \ Debug \ \ Exception \ FatalThrowableError (code: 0): Parse error: syntax error, unexpected '?', Expecting variable (T_VARIABLE) at /home/vagrant/Code/laravel56/vendor/symfony/routing/Route.php:53)
[stacktrace]
...

Has anyone gone through this? Do you know how I can solve it?

Note: My Homestead is up to date, it is in the latest version.

28 Nov
1 year ago

leandromatos started a new conversation Improving Teamwork With Linters In Laravel Mix

Something I miss about Laravel Mix is the use of linters by default to standardize the js, css and vue codes, by more than one person.

Has anyone ever experienced this? How to solve? What if Laravel Mix has it natively? Is it a good idea @JeffreyWay?

01 Aug
2 years ago

leandromatos left a reply on Can't Get Email Verification Link On Hotmail , Yahoo

@Amelie89 , Try to use a service for sending e-mails. One good is Sparkpost, you can sending 10K emails/month free.

https://www.sparkpost.com/

leandromatos left a reply on Multiple SASS Files

@osherdo, It seems to me that one of your files have dependencies to other files. You may need to make other imports before, is just what I can imagine.

leandromatos left a reply on Multiple SASS Files

Sorry, import, not include. I edited my comment.

leandromatos left a reply on Multiple SASS Files

@osherdo, Include directly in app.scss file.

Something like:

@include('buttons.scss');
@include(''dropzone.scss');

I always includes all css within the app.scss, thus only need to declare app.scss in the gulpfile.

leandromatos left a reply on Can't Get Email Verification Link On Hotmail , Yahoo

@Amelie89 Which service you use for send emails?

leandromatos left a reply on Get List Item Value Outside Of Loop

In this case e.target need be change to e.currentTarget, maybe works!

leandromatos left a reply on Where Are You All From?

Belo Horizonte, MG, Brasil

leandromatos left a reply on Get List Item Value Outside Of Loop

@tykus_ikus But the click happens in the child element.

leandromatos left a reply on Relationsships And Dynamic Properties

You can call fresh() method on your model. It will reload the model from the database and return it. Keep in mind that it returns a reloaded object - it doesn't update existing one. You can also pass an array of relations that should be reloaded:

$model = $model->fresh($relations);

leandromatos left a reply on Get List Item Value Outside Of Loop

Put in your 15 items one click to a method with the event, within the method you redeem the item text.

Something like:

<ul>
    <li @click="getText($event)">Text</li>
    ...
</ul>

and

...
methods: {
    getText: function(e) {
        console.log(e.target innerHTML)
    }
}
...

leandromatos left a reply on Larval Blade As Vue Router's Template !!

Their approach is correct in my opinion, but, if you need to use a Vue Router in others parts of the code, maybe best approach is creates a method for load all resources.

leandromatos left a reply on Best Approach For Use Presenters And Helpers?

I do not know if my approach was correct, however, I created a class of service that works best with the controller, thus I no longer use the helper directly accessing a repository.

leandromatos left a reply on Controller With Access To Multiple Repositories, It Is A Good Practice?

I created a new layer of services between the controller and the repository, the practice now is certainly better.

leandromatos left a reply on Show Different Header For Three Guards

Try using dd() with your 3 guards for debug. What results?

leandromatos left a reply on This Can Give Problems?

You can use different methods for authorize a action if use policies.

https://laravel.com/docs/master/authorization#authorizing-actions-using-policies

leandromatos left a reply on Show Different Header For Three Guards

Try to use @elseif and @else.

@if(...)
    // menu 1
@elseif(...)
    // menu 2
@else 
    // menu 3
@endif

leandromatos left a reply on Can't Get Email Verification Link On Hotmail , Yahoo

Try to use sparkpost.com for sending yours emails!

31 Jul
2 years ago

leandromatos left a reply on Auth/logout Redirecting Too Many Times

Try to make a treatment to display the error message only when you have an error.

@if(session('error')
// code for display error
@endif

leandromatos left a reply on Auth/logout Redirecting Too Many Times

If you use version 5.2, these are the routes. Try using them.

Route::get('login', ['as' => 'auth.login', 'uses' => 'Auth\[email protected]']);
Route::post('login', ['as' => 'auth.login', 'uses' => 'Auth\[email protected]']);
Route::get('logout', ['as' => 'auth.logout', 'uses' => 'Auth\[email protected]']);

// Registration Routes...
Route::get('register', ['as' => 'auth.register', 'uses' => 'Auth\[email protected]']);
Route::post('register', ['as' => 'auth.register', 'uses' => 'Auth\[email protected]']);

// Password Reset Routes...
Route::get('password/reset/{token?}', ['as' => 'auth.password.reset', 'uses' => 'Auth\[email protected]']);
Route::post('password/email', ['as' => 'auth.password.email', 'uses' => 'Auth\[email protected]']);
Route::post('password/reset', ['as' => 'auth.password.reset', 'uses' => 'Auth\[email protected]']);

leandromatos left a reply on Auth/logout Redirecting Too Many Times

Anyway, put it in your AuthController

public function __construct()
{
    $this->middleware($this->guestMiddleware(), ['except' => 'logout']);
}

leandromatos left a reply on Auth/logout Redirecting Too Many Times

The redirect happens in login or logout? Your question stayed confused.