Member Since 4 Years Ago

Experience Points 12,920
Experience Level 3

2,080 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 226
Best Reply Awards 0
Best Reply
  • 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


    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement


    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.

29 May
3 years ago

AlexMunoz started a new conversation Set Parent For Vue Component


After performing an ajax call in my application I get a list of anchors in my view, then I convert them to vue components using the following code:

var anchorAjaxELements = document.getElementsByClassName('test');

for (var i = 0; i < anchorAjaxELements.length; i++) {
       var item = anchorAjaxELements[i];
       var href = item.href;
       var text = item.text;

       var anchorAjaxComponent = Vue.component('anchor-ajax');
       var anchorAjax = new anchorAjaxComponent().$mount(item);
       anchorAjax.url = href;
       anchorAjax.text = text;
Everything works just fine. The only problem is that the parent is not set for the created components even though I registered the anchor-ajax component globally. How can I set the parent instance?

Here is  the code for my component:

import Vue from 'vue';

export default Vue.extend({

template: `
<a v-on:click.prevent="onClick" v-bind:href="url">

replace: true,

data (){
    return {
        url: '',
        text: '',


23 May
3 years ago

AlexMunoz started a new conversation How To Concatenate String When Passing A Property


I know this is an easy one but for some reason I can't find the solution.

I have a section title compontent. I'm using it like this:

 <section-title :title="Test"></section-title>

But I want to concatenate a variable and a string and pass it as the title property.

I have tried the following approaches with no luck.

 <section-title :title="@{{Variable}} Test"></section-title>
 <section-title :[email protected]{{variable + 'test'}}></section-title>


20 May
3 years ago

AlexMunoz started a new conversation How To Create Data Store In Blade Template


I'm trying to implement a data store for state management as recommended in here:

Jeffrey also taked about this in Lesson 18 of the Vue series.

My question is, what would be the correct way to create the data variable inside a Blade template?


07 May
3 years ago

AlexMunoz started a new conversation Eager Load Multiple Nested Relationships


I'm trying to eager load a couple of nested relationships but I'm unsure on how to do it.

Currently I have this code:

$sector = Sector::with('companies.meetings', 'processes')->find('1');


So I'm eager loading one of the companies relationships and lazy eager loading the other one.

Is there a better way to handle this?

29 Apr
3 years ago

AlexMunoz left a reply on Problem With Custom Primary Key And Many To Many Relationship

After further inspection I found that the Sector primary key ('code') was being casted, that's why it was returning a 0 instead of the appropiate value.

Adding this property to the Sector model solved the issue.

public $incrementing = true;

This property must be set when the model is not using an autoincremental primary key.

Thanks @willvincent and @jekinney for your time and help.

AlexMunoz left a reply on Problem With Custom Primary Key And Many To Many Relationship

@willvincent thanks for your response. The problem is that the column on the pivot table is name not code. So contains the sector code. (I know it doesn't make much sense but that's how the database was designed and I can't modify it).

AlexMunoz left a reply on Problem With Custom Primary Key And Many To Many Relationship

@jekinney Sorry but I don't get your answer. I'm just trying to define a relationship.

What I showed at the end was the query that is generated by the query builder. ( I'm not using raw queries.

AlexMunoz started a new conversation Problem With Custom Primary Key And Many To Many Relationship


I have three tables: company, sector, company_sector.

Company relevant fields: user_id (primary) Sector relevant fields: code (primary), name Company sector relevant fields: id (primary), user_id, name

I'm trying to stablish a belongsToMany relationshop between Sector and Company like this but it's not working

$this->belongsToMany('App\Sector', 'company_sector', 'user_id', 'role_id');

I have setup the primary keys in both the Sector and the Company models.

On sector:

protected $primaryKey = 'code';

On company:

protected $primaryKey = 'user_id';

This is what I get when I print the query logger:

"query" => "select `companies`.*, `company_sector`.`name` as `pivot_name`, `company_sector`.`user_id` as `pivot_user_id` from `capim_companies` inner join `company_sector` on `companies`.`user_id` = `company_sector`.`user_id` where `company_sector`.`name` = ?",
       "bindings" => [

The query is fine but the binding is empty, I should be seeing the sector code there.

Any ideas on how to resolve this?


AlexMunoz left a reply on Custom Index Relationships

@spekkionu I'm working on a side project. The datbase is used in multiple projects that I don't manage and I unfortunately I can't change the structure.

12 Apr
3 years ago

AlexMunoz left a reply on Custom Index Relationships

@DNoe thanks for your input! I got it to work using the built in functionallity. I added a property to my model using the $appends property on the model. I used that attribute as the foreign key and it worked.

Here is my working code:


namespace Capim;

use Illuminate\Database\Eloquent\Model;

class Company extends Model

    protected $table = 'companies';

    protected $appends = ['state_code'];

    public function getStateCodeAttribute(){
        return json_decode($this->data)->state_code;
    public function state(){
        return $this->belongsTo('Capim\State', 'state_code', 'code') ;



AlexMunoz started a new conversation Custom Index Relationships


I have two tables: company and state.

On the company table I have a field called data that stores a json. Inside this json there is a property called state. I would like to define a "belongs to" state relationship on the company model. Is there any way I can achieve this? Since state is not an actual column on the company table I don't know if this is possible.


10 Apr
3 years ago

AlexMunoz left a reply on Help With Class Mocking

Ok, so if I Mock it like this it works:

$mock = Mockery::mock('App\Interact\InteractManager');

Still don't understand why it doesnt work when using the facade.

AlexMunoz started a new conversation Help With Class Mocking

Hello I'm new to testing and I'm having some problems when trying to mock a class.

I have a dependency named Interact. This is Interact Service Provider:

namespace App\Interact;

use Illuminate\Support\ServiceProvider;

class InteractServiceProvider extends ServiceProvider
    public function register()
        $this->app->singleton('App\Interact\Contracts\Factory', function($app){
            return new InteractManager($app);

This is an extract from the Interact Manager Class which is ultimately what is resolved when typehinting the Interact Factory interface:

namespace App\Interact;
use Doctrine\Instantiator\Exception\InvalidArgumentException;
use Illuminate\Support\Manager;

use App\Interact\Contracts\Factory;

class InteractManager extends Manager implements Factory

    public function with($driver = null){
        return $this->driver($driver);

The class that I'm trying to test is called Aggregator and it uses Interact. I'm using contructor injection as you can see the the code below.

namespace App;
use App\Interact\Contracts\Factory;

class Aggregator

    protected $interact;

    public function __construct(Factory $interact)
        $this->interact = $interact;

Finally on my test I'm trying to Mock the Interact dependency as follows (I have created a Facade for Interact)

use App\Aggregator;
use App\Interact\Facades\Interact;

class AggregatorTest extends TestCase

    public function test_aggregator()
        $interactMock = Interact::shouldReceive('with')->with('facebook');

        $aggregator = new Aggregator($interactMock);

When trying to run the test I get the following error:

TypeError: Argument 1 passed to App\Aggregator::__construct() must implement interface App\Interact\Contracts\Factory, instance of Mockery\CompositeExpectation given

If I dump $interactMock I get this:

#_mock: Mockery_0_App_Interact_InteractManager

And since it is an InteractManager Mock I would suspect that it implements the correct interface.What am I missing here?

Thank you so much for your time and help.

12 Feb
3 years ago

AlexMunoz started a new conversation Change The Property V-model Of A Select Tag In Vue.js

I have a form where the user select a number between 1 and 4 with a select tag, with the property of v-model="screens".

According to the number selected, with v-for="screen in screens" new select tags with options between 1 and 3 are showed to the user. For example if the user select 3, then 3 select tags are showed. This second tags need to have also a v-model="????".

Then if in the second select the user select the number 3, three inputs are showed to the user also with v-for="??? in ????".

The problem is that I don't know how to change the v-model property of the second select so that the inputs are not connected between them.

20 Jun
4 years ago

AlexMunoz left a reply on Use PasswordBroker On Controller

@MarkRedeman Thank you Mark. Your response was very helpful for me. I'll follow your advice.

AlexMunoz left a reply on Use PasswordBroker On Controller

@MarkRedeman Thank you for your reply.

I call it from another method in the controller.

If I use constructor injection I can get it to work.

use Illuminate\Auth\Passwords\PasswordBroker

and the constructor 

public function __construct(PasswordBroker $passwords) { $this->passwords = $passwords;


and then on **sendPasswordResetEmail** I can use $this->passwords.

But I want to do it via method injection. So I'm trying to use the **PasswordBroker** interface. On my **AppServiceProvider** I added this on the **register** method:

$this->app->bind( 'Illuminate\Contracts\Auth\PasswordBroker', 'Illuminate\Auth\Passwords\PasswordBroker' );

I'm pretty sure I'm missing something fundamental, I'm still learning how the Service Container works.

Thank you once again.  


AlexMunoz started a new conversation Use PasswordBroker On Controller

Hello everyone,

I want to use the PasswordBroker class on one method of a controller.

I added this line at the top of my controller:

use Illuminate\Contracts\Auth\PasswordBroker;

And on my method:

private function sendPasswordResetEmail(PasswordBroker $passwords){

But I keep getting the following error: Argument 2 passed to App\Http\Controllers\Admin\PlayerController::sendPasswordResetEmail() must be an instance of Illuminate\Contracts\Auth\PasswordBroker, none given, called in /home/vagrant/Code/soccerbros/app/Http/Controllers/Admin/PlayerController.php on line 52 and defined

Any help is appreciated.

Thank you