Our Black Friday sale is now live! All individual subscriptions are 50% OFF. This week only!

eballeste

eballeste

Member Since 5 Months Ago

Experience Points
8,720
Total
Experience

1,280 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
84
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start your 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-in-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 Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist 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.

Level 2
8,720 XP
Nov
20
4 days ago
Activity icon

Replied to Pass Variable To Included Livewire Component

i see where your problem is, you were doing this:

        return view('livewire.tasks', [
            'deals' => $deals
        ]);

when you should of been doing this:

        return view('livewire.tasks', [
            'deals' => $this->deals
        ]);
Activity icon

Replied to Pass Variable To Included Livewire Component

Looks like the accepted answer is not really the case. I was thinking about querying from within the livewire controller and I too found it weird that I would have to do this query a second time when I already had it.

The issue with the original poster was that he was passing a non existent variable into the livewire view, passing in $deals (which is scoped to the render method) instead of the variable scoped to the class: $this->deals.

I can pass a collection from my laravel controller into a normal blade view and from there inject the variable as a parameter into the livewire component, then from this component's controller class into the livewire view and it is parsed correctly without needing to convert it into an array beforehand like one of the comments mentioned above. Everything should just work.

Blade View called by Laravel controller:

<x-layouts.admin>
	<livewire:projects-dashboard :projects="$projects">
</x-layouts.admin>

Livewire Controller:

<?php

namespace App\Http\Livewire;

use Livewire\Component;

class ProjectsDashboard extends Component
{
    public $projects; // livewire auto-assigns component parameter to this variable

    public function render()
    {
        return view('livewire.projects-dashboard', [
            'projects' => $this->projects, // passing in variable into livewire view
        ]);
    }
}

Livewire View:

@foreach($projects as $project)
    <a href="projects/{{ $project->slug }}">{{ $project->name }}</a>
@endforeach
Sep
09
2 months ago
Activity icon

Replied to Laravel 8 Model Factory Namespaces

figured this out with a custom trait and adding a callback to the guessFactoryNamesUsing static method of the Factory before calling the factoryForModel static method:

     /**
     * Get a new factory instance for the model.
     *
     * @param  mixed  $parameters
     * @return \Illuminate\Database\Eloquent\Factories\Factory
     */
    public static function factory(...$parameters)
    {
        Factory::guessFactoryNamesUsing(function (string $modelName) {
            // your custom logic to extract the classname from the fully resolved class name
           $modelName = ... ;
 
	   return 'Database\\Factories\\'.$modelName.'Factory';
        });

        return Factory::factoryForModel(get_called_class())
            ->count(is_numeric($parameters[0] ?? null) ? $parameters[0] : null)
            ->state(is_array($parameters[0] ?? null) ? $parameters[0] : ($parameters[1] ?? []));
    }
Activity icon

Replied to Laravel 8 Model Factory Namespaces

Hi! I was upgrading today as well and ran into this problem when using custom namespaces. My initial gut instinct was to do what you guys mentioned and just match the namespace of the factories with that of the models but it's kind of weird and doesn't make much sense to me to have to do so.

I know you guys stated that we don't have to overwrite the factoryNameResolver but I'm looking at this code and it looks like we can? What is static::$factoryNameResolver?

Aug
04
3 months ago
Activity icon

Commented on Scoping Projects

someone checked in the comments above and found this:

public function actingAs(UserContract $user, $driver = null)
{
    return $this->be($user, $driver);
}
    	
Activity icon

Commented on Scoping Projects

just a guess but I think the difference here is that in the User model, the method name doesn't influence what relationship key to look for (because it is hasMany) so it's based on the User model user_id, forcing Jeffery to adjust it to owner_id since that is what he used in the projects table.

in the Project model, since the owner method has a belongsTo relationship I think Laravel is using that method name, instead of the model name to automagically look for owner_id as the relationship key.

Jul
11
4 months ago
Activity icon

Commented on Testing Request Validation

thought about it a little bit more and I think it's because feature tests are testing http related crud features while unit tests just test single methods within a model. amirite? i dunno

Activity icon

Commented on Testing Request Validation

I'm wondering why a_site_requires_a_name and a_site_requires_a_description weren't added as unit tests?

Jun
27
4 months ago
Activity icon

Commented on Let's Begin With A Test

is there any reason why you used the singular form instead of the plural form for the named route?

Jun
26
4 months ago
Activity icon

Commented on Step 10: Functions

Maybe you can start your own conventions like starting all your functions in question form with is when you know you want to return a bool to use in conditionals.

isHuman isLegalAge isValidKey

etc etc.

Jun
22
5 months ago
Activity icon

Commented on Step 10: Functions

Another thing to consider is the name of the function, checkAge doesn't really tell you much about the function, what are you checking about the age? It would be easier to understand if you called your function isLegalAge

function isLegalAge($age) {
  return $age >= 21;
}

then when used in your code it would look like this when used with conditionals:

if ( isLegalAge($age) ) { ... } 

or

if ( !isLegalAge($age) ) { ... }

it's just easier to understand what your intentions are with the code because you can read it out like a normal sentence:

if is legal age: do this

or

if not is legal age: do that

you can't do that with checkAge as the name.

Jun
21
5 months ago
Activity icon

Commented on Step 7: Associative Arrays

in some code editors, if you type the quote (single or double) it will automatically add the closing quote and place the cursor within it, then after you type what you want, yes, you use the right arrow key to move the cursor out of the quotes.