Member Since 1 Year Ago


Software Engineer at Latcom

Experience Points 9,440
Experience Level 2

560 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 92
Best Reply Awards 0
Best Reply
  • start-engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-session Created with Sketch.

    School In Session

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

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

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

  • subscriber-token Created with Sketch.


    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.


    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist Created with Sketch.

    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 Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

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

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

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

11 Sep
1 week ago

okusax left a reply on Error Uploading Photo

The error is throw because you forgot to import Str helper.

use Illuminate\Support\Str;

$fileName = Str::random(40);

You can use laravel Storage facade tu handle files uploads/downloads easily: https://laravel.com/docs/5.8/filesystem

08 Jul
2 months ago

okusax left a reply on How To Use Laravel Passport API On Your Site For Logging In And Recieving User Data

I think you can log into https://customer.website.com form and request a token with the provided data to https://api.website.com, if the request success then you save the returned token and log into the customer system (maybe saved the token in cache?).

I don't understand if you will use api.website only for login or for login and get/post data. If is only for login then you are done, just remember to expire the token when user logout or after certain time.

If you will use it for login and get/post data after login when you need to request any data, you make a request from customer.website backend to api.website request adding an authorization header with the saved token. This last will be a little slow because it uses two requests to solve authorized requests but it will works.

okusax left a reply on Return Single Related Resource In A Resource

Hi, you want also to change the returned element key 'products' to 'product' when returning only one product?

How would you manage the case when no products are related to that user?

If you want to change the key name you can use conditional attributes https://laravel.com/docs/5.8/eloquent-resources#conditional-attributes checking for the length of the products collection. And maybe query for something like 'product' => ProductResource(Product::find('user_id', $this->id))

I think is better to manage all as a collection products and when you only have one its only a special case of a collection with only one element.

05 Jun
3 months ago

okusax left a reply on Creating A Model B Inside Model A

can you share all the code of addInvoiceValue()?

29 Nov
9 months ago

okusax left a reply on LUMEN Error : In Container.php Line 824: Class App/Console/Commands/KeyGenerateCommand Does Not Exist

remember to run:

composer dump-autoload

after the addition of a class to the project.

okusax left a reply on Request Status Code 404 Not Found

Remember to enable Options +FollowSymLinks and enable mod_rewrite in apache

27 Nov
9 months ago

okusax started a new conversation Eloquent Queries

Hi, Im having some trouble understanding eloquent. I know that this ORM never uses joins to solve the queries but I don't understand how to get data in complex relations without making a lot of queries to the system.

In my example I have:

- id
- name
- id_type
- id_place

- id
- name
- id_clasification

- id
- name
- id_sub_type

- id
- name
- id_group

- id
- name

- id
- name
- id_owner

- id
- name

An element belogsTo an ElementType that belongs to a ElementClasification, etc and is placed in a Place owned by an Owner.

If I want to get all elements of certain type, clasification, subtype and group that are placed in places that are owned by certain Owner. How would you make that query?

Normally in this cases I use lots of whereHas loading all the relations and inside the whereHas y place a condition. I think this is a little inefficient when the tables start to grow.

22 Feb
1 year ago

okusax left a reply on Lumen-passport Throws FatalThrowableError


Dusterio\LumenPassport\LumenPassport::routes($app, ['prefix'=> 'api/v1']);

from bootstrap/app.php, the routes are loaded when you run


in app/provider/AuthServiceProvider.php

08 Jan
1 year ago

okusax left a reply on Handle Errors On API Laravel 5.5

@topvillas i was thinking in the future it can be extended to add support to other types of errors, I think a trait can be the way to go.


05 Jan
1 year ago

okusax started a new conversation Handle Errors On API Laravel 5.5

Hi, Im making an API using Resources. The way to handle errors in Controllers I'm using for now is defining some try{}catch{} and then if some error occurs return something like:

                'errors' => [[
                    'code' => 'ERR-404',
                    'title' => 'Not Found',
                    'details' => 'Element Not Found'
            ], 404);

But Im not happy with it... How are you handle this situations? There's a native way in laravel to do that?

I'm thinking in make an Error class and define inside the logic to make the error and his attributes but maybe there is a better way.


02 Jan
1 year ago

okusax left a reply on Invalid Text Representation Using Route Model Binding

@burlresearch hi, happy new year! I expllicit bind the model as says in https://laravel.com/docs/5.5/routing#explicit-binding

public function boot()
    Route::model('elements', \App\Models\Element::class); // I put the models on that folder

But Im getting the same error... Can be a laravel 5.5.28 bug?

29 Dec
1 year ago

okusax started a new conversation Invalid Text Representation Using Route Model Binding

Hi, Im testing implicit route model binding, so I define a resource controller and a resource route for it:


public function show(Element $element)
return view('elements.show', compact('element'));


Route::resource('elements', 'ElementController');

Elements migration:

public function up()
        Schema::create('elements', function (Blueprint $table) {





if I access /elements/1 or /elements/2 everythings is allrigth (get elements description as defined in the view or 404 if not found). But accessing /elements/a or anything like: /elements/string throw:

SQLSTATE[22P02]: Invalid text representation: 7 ERROR: invalid input syntax for integer: "a" (SQL: select * from "elements" where "id" = a limit 1)

So when the ElementController call show() laravel execute Element::find('a') and Eloquent make a valid query but with invalid id type... There is a way to catch this error and show 404 page before the show method try to found the element using an incorrect id type?