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

Alfie

Alfie

Member Since 5 Months Ago

Experience Points
11,680
Total
Experience

3,320 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
105
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 3
11,680 XP
Nov
19
4 days ago
Activity icon

Commented on Branching

For that case you swap out to the master or dev branches fix that bug and commit, then get back to your reporting feature branch and merge in the branch where you just fixed that about bug into the feature branch.

Here the important thing will be the merging conflicts that pulling updated code on some your working files can occur.

I think later on Jefrey will talk about merging.

Nov
18
5 days ago
Activity icon

Replied to Laravel Breeze - Sending Registration Emails + Email Customizations

Adding on top of that, would you like to explain why MustVerifyEmail is an interface and not a trait ?

Nov
11
1 week ago
Activity icon

Commented on Nav Link Component

Heres a component in case you need to have active states on named routes with .create .show etc... i built it on top of @dascentral 's href suggestion for named and href routes.

@props(['href', 'route'])

@php
$active = str_contains(Route::currentRouteName(), Str::beforeLast($route, '.')); //el uso de Str before last es para solo tener el nombre sin .create .show etc...
$classes = $active
            ? 'inline-flex items-center px-1 pt-1 border-b-2 border-indigo-400 text-sm font-medium leading-5 text-gray-900 focus:outline-none focus:border-indigo-700 transition duration-150 ease-in-out'
            : 'inline-flex items-center px-1 pt-1 border-b-2 border-transparent text-sm font-medium leading-5 text-gray-500 hover:text-gray-700 hover:border-gray-300 focus:outline-none focus:text-gray-700 focus:border-gray-300 transition duration-150 ease-in-out';
@endphp

<a href="{{ isset($route) ? route($route) : $href }}"  {{ $attributes->merge(['class' => $classes]) }}>
    {{ $slot }}
</a>
Nov
10
1 week ago
Activity icon

Replied to Jetstream Toast

Thanks a bunch man!, wasn't able to find the trigger.

Activity icon

Started a new Conversation Jetstream Toast

Hello all! In the new Jetstream profile section there's, if activated, the change password form, which inside has this action message (toast):

<x-jet-action-message class="mr-3" on="saved">
            {{ __('Saved.') }}
 </x-jet-action-message>

Any one knows when or what toggles the on="saved" in order to trigger the visibility and set the time out function inside the alpine based component?

Thanks in advance

Nov
05
2 weeks ago
Activity icon

Replied to How To Create Custom Email Verification Template | Laravel 5.7

Change 'verification.verify' with your custom named route on this lines :

$verifyUrl = URL::temporarySignedRoute(
                'verification.verify',

And you pass the parameters for the url request in here:

		[
                    'id' => $notifiable->getKey(),
                    'hash' => sha1($notifiable->getEmailForVerification()),
                ]
Oct
26
4 weeks ago
Activity icon

Replied to Component Not Rendering With A Conditional

Im working with Laravel 8, tried your solution but it doesn't work either.

@if ($hasSubType)
	<x-custom-select :model="$subTypes" wire="selectedSubType" label="Sub-Tipo" class="w-1/2" /> 
@endif

i solved it by hidding the field for now, but if any one reads this and has a solution of why it doesn't render would appreciate it

Activity icon

Replied to Datepicker With TailwindCSS, AlpineJS, Laravel & Livewire

Hey man i was wondering if you where you able to fix the JS issue while changing months with the arrows?

Activity icon

Started a new Conversation Component Not Rendering With A Conditional

Hello all!

I have the following blade component :

<x-custom-select :model="$subTypes" wire="selectedSubType" label="Sub-Tipo" class="w-1/2"  {{ $hasSubType ? 'disabled' : '' }}/>

<x-custom-select :model="$subTypes" wire="selectedSubType" label="Sub-Tipo" class="w-1/2"   @if ($hasSubType) disabled @endif />

in any of the cases the component doesn't render , the property $hasSubType is present if i print it inside a p/span tag or similar but it breaks the component.

This is the component construct code

public function __construct($model, $wire, $label, $disabled = false)
    {   
        $this->options = $model;
        $this->wire = $wire;
        $this->label = $label;
        $this->disabled = $disabled;
    }

Any ideas whats could be happening?

Activity icon

Commented on Dropdown Component

This is a topic i haven't been able to find a nice mid level tutorial or explanation

Activity icon

Replied to Invalid Argument Supplied For Foreach()

That was it , needed to declare it as an empty array.

And yes it needs to have the data on mount / contruct in this case .

Thanks Man!

Activity icon

Started a new Conversation Invalid Argument Supplied For Foreach()

Hello all - I'm having issues passing an elocuent model to a custom select component

This is the view that renders the component

<x-custom-select :model="$types" label="Tipo" class="w-1/2"/>

This is the component view code

@foreach($options as $option)
    <option
          value="{{$option->id}}"
          {{ $isSelected($option->id) ? 'selected="selected"' : '' }}
          >
      {{ $option->name }}
    </option>
@endforeach

This is the component class

class CustomSelect extends Component
{
    public $model;
    public $label;
    public $options;
    public $selected;
    
    /**
     * Create a new component instance.
     *
     * @return void
     */
    public function __construct($model, $label)
    {   
        $this->model = $model;
        $this->label = $label;
    }

    /**
     * Get the view / contents that represent the component.
     *
     * @return \Illuminate\Contracts\View\View|string
     */
    public function render()
    {   
        return view('components.custom-select')->with('options', $this->model);
    }
}

And this is the $model passed down via the construct method

Illuminate\Support\Collection {#1368 ▼
  #items: array:5 [▼
    "Juicio" => 1
    "Dictamen" => 2
    "Oficio" => 3
    "Procedimiento" => 4
    "Restructura" => 5
  ]
}

I've already tried passing the data into de component with all this different syntaxes but without successful results in any case.

:model="$types"
model="$types"

:model="{{$types}}"
model="{{$types}}"

:model="{!!$types!!}"
model="{!!$types!!}"

:model="'$types'"
model="'$types'"

Each one produces different results in the $methods variable, i even tried casting the eloquent model to array or plucking it, but i can't figure why it won't let me render it.

Any idea what im missing?

Oct
19
1 month ago
Activity icon

Replied to Strange Model Save Behavior With Livewire

Yes got it resolved, dunno what's was the exact error but had to do with the validation order on the original submitForm method.

And yes the email uniqueness is working as intended now.

Thanks for your pointers, helped me debug it.

Activity icon

Awarded Best Reply on Strange Model Save Behavior With Livewire

It's validated also on update because you can update the users mail with an existing one.

But, by checking that i found the issue:

The validation had to happen before user::create So i ended up with 2 separate methods:

public function createNewUser()
    {
        $this->validate();

        User::create([
            'is_admin'          => false,
            'role'              => $this->role,
            'name'              => $this->name,
            'email'             => mb_strtolower(trim($this->email)),
            'password'          => Hash::make(Str::random(6)), //Str::random(6)
            'is_active'         => true,
        ]);

        session()->flash('status', 'Usuario creado correctamente');
        $this->resetForm();
        $this->redirectRoute('users.show');
    }
public function updateUserData()
    {
        $this->validate();

        $this->user->role     = $this->role;
        $this->user->name     = $this->name;
        $this->user->email    = mb_strtolower(trim($this->email));

        $this->user->save();

        session()->flash('status', 'Usuario actualizado correctamente');
        $this->resetForm();
        
        return $this->redirectRoute('users.show');
    }

So the submitJust validates if its a creation or edition mode.

public function submitForm()
    {
        $this->user ? $this->updateUserData() : $this->createNewUser();
    }

Ohh and thanks also for pointing out about that user was already a Eloquent model, saved me one query

Thanks Man!!

Activity icon

Replied to Strange Model Save Behavior With Livewire

It's validated also on update because you can update the users mail with an existing one.

But, by checking that i found the issue:

The validation had to happen before user::create So i ended up with 2 separate methods:

public function createNewUser()
    {
        $this->validate();

        User::create([
            'is_admin'          => false,
            'role'              => $this->role,
            'name'              => $this->name,
            'email'             => mb_strtolower(trim($this->email)),
            'password'          => Hash::make(Str::random(6)), //Str::random(6)
            'is_active'         => true,
        ]);

        session()->flash('status', 'Usuario creado correctamente');
        $this->resetForm();
        $this->redirectRoute('users.show');
    }
public function updateUserData()
    {
        $this->validate();

        $this->user->role     = $this->role;
        $this->user->name     = $this->name;
        $this->user->email    = mb_strtolower(trim($this->email));

        $this->user->save();

        session()->flash('status', 'Usuario actualizado correctamente');
        $this->resetForm();
        
        return $this->redirectRoute('users.show');
    }

So the submitJust validates if its a creation or edition mode.

public function submitForm()
    {
        $this->user ? $this->updateUserData() : $this->createNewUser();
    }

Ohh and thanks also for pointing out about that user was already a Eloquent model, saved me one query

Thanks Man!!

Activity icon

Started a new Conversation Strange Model Save Behavior With Livewire

Hello all!

I'm curious if anyone know why this happens, i'm updating a model data on a live wire component and right now i have it like this:

public function submitForm()
    {
        $this->validate();

        if ($this->user) {

            $user = User::find($this->user->id);
            $this->validate();

            $user->role     = $this->role;
            $user->name     = $this->name;
            $user->email    = mb_strtolower(trim($this->email));

            $user->save();

            $this->emitTo('toaster', 'showToast', 'Usuario actualizado correctamente');
            // session()->flash('status', 'Usuario actualizado correctamente');
            $this->resetForm();

            return $this->redirectRoute('users.show');
        }

        User::create([
            'is_admin'           => false,
            'role'              => $this->role,
            'name'              => $this->name,
            'email'             => mb_strtolower(trim($this->email)),
            'password'          => Hash::make(Str::random(6)), //Str::random(6)
            'is_active'          => true,
        ]);

        $this->emitTo('toaster', 'showToast', 'Usuario creado correctamente');
        $this->resetForm();
        $this->redirectRoute('users.show');
    }

and it works just fine, the problem comes when i try to extract the update method out of the submitForm like this

if ($this->user) {

            $user = User::find($this->user->id);
            $this->updateUserData($user);

If i extract the logic into that new updateUserData($user) method when i try to save it triggers the unique mail rule.

Any one know why this happens?

Oct
16
1 month ago
Activity icon

Replied to L8 - Jetstream Is_active Custom Rule - Howto

Nice rabbit hole you have sent me into =) Thanks.

Found an article from @snapey that looks promising.

Activity icon

Replied to L8 - Jetstream Is_active Custom Rule - Howto

Nothing wrong, just wondering if there was a new way of doing it by giving additional parameters to the given scaffold.

With this one i will need to implement my own logic, not that is a lot but Jetstream promise everything out of the box so was just curious if the was something im not seeing.

Oct
15
1 month ago
Activity icon

Started a new Conversation L8 - Jetstream Is_active Custom Rule - Howto

Hello all!!

Im trying to implement a custom rule "is_active" at login view on a new jetstream based proyect.

The docs suggest making a custom login controller and use this:

	$credentials = $request->only('email', 'password');
        $credentials['is_active'] = true;

        if (Auth::attempt($credentials)) {

            return redirect('/');

        } 

I was wondering if there's a better/proper way to extend Fortify functionality ?

Oct
14
1 month ago
Activity icon

Replied to Laravel 8 Jetstream - Add Data On 1 Screen, Appears Automatically On Another.

I think you just need to wire your livewire model to the form and on page2 you just need to query the model on the render method every new record created with the form should appear automatically.

Activity icon

Replied to Livewire - Missing Value In Form Submit

I spotted a typo here:

:class="{ 'arsch': tab === 'questions' }"

Although it doesn't has to do with your error

Oct
12
1 month ago
Activity icon

Replied to X-component Input Errors Not Showing

Great , thanks a bunch man, one of he hardest part in programing for me is this kind of stuff, glad that here's a community that supports you.

Oct
11
1 month ago
Activity icon

Started a new Conversation X-component Input Errors Not Showing

Hello all!!

I'm trying to make my own custom input fields and they work just fine until i try to validate them, when i use

  @error('{{ $model }}')
      <p class="w-full text-sm text-red-500 mt-1"> {{ $message }}</p>
  @enderror

in this case the component looks like this:

<x-input type="email" model="email" label="E-mail" placeholder="[email protected]"/>

Any ideas why it's not getting the error , the form used to validate properly with the input right on the form with the traditional @error('mail') directive.

Thanks in advance

Oct
09
1 month ago
Activity icon

Replied to Escaping Variable Inside {{ Route() }}

That works too

"God i feel such a nuub with this type of questions" -but hey fundamentals are a thing on its own.

Thanks man! You surely are taking the lead ahead of Bobby, Kudos to you!!!

Appreciate the time.

Activity icon

Replied to Escaping Variable Inside {{ Route() }}

It's working now with " $endpoint.'.create' " notice the 2 periods.

God this hard like college math with signs

Activity icon

Replied to Escaping Variable Inside {{ Route() }}

prints this-> <a href="<?php echo e(route($endpoint.'create')); ?>" class...

Activity icon

Replied to Escaping Variable Inside {{ Route() }}

forgot to add the semicolons('') on the post but they are present in the code

{{ route('$endpoint.create') }} 
Activity icon

Started a new Conversation Escaping Variable Inside {{ Route() }}

Hello all! im trying to pass down a variable inside a component (in this case route="") like this:

<x-page-header title="Clients" endpoint="clients"/>

And inside the component i've already tried with:

<a href="{{ route($endpoint.create) }}" class...
<a href="{{ route(´$endpoint´.create) }}" class...
<a href="{{ route(/´$endpoint´/.create) }}" class...
<a href="{{!! route($endpoint.create) !!}}" class...

But it wont let me render it properly. How would can i resolve it?

Thanks in advance!

Oct
06
1 month ago
Activity icon

Replied to Try To Use Laravel 8 And Livewire

Hello guys, in the nav-link.blade.php file i find this lines of code that build the links.

<a {{ $attributes->merge(['class' => $classes]) }}>
    {{ $slot }}
</a>

Can you please point if the slot comes from:

<x-jet-nav-link href="{{ route('/') }}" :active="request()->routeIs('clients')">
       Nav-Menu-Link 
</x-jet-nav-link>

Where "Nav-Menu-Link" is the slot passed down to the component?

And why the route in the href says isn't defined :

ErrorException Route [/] not defined.

im unable to navigate on my app because of this routing problems. 😢

Sep
03
2 months ago
Activity icon

Commented on Encapsulation

Is this more intended for IDE's knowing what is exposed and able to prompt class available methods? or is it intended to prevent malicious data manipulation on our objects on production code? or Just good practice like using nice grammar and punctuation while writing. -Not my case here lol. -

Jun
12
5 months ago
Activity icon

Commented on Expanding The Timeline

I don't quite understand why sometimes the method is called with this syntax: $this->follows; and some others like this: $this->follows();

I noticed the second returns just the eloquent collection but it doesn't list the items like in the first case.

Where can i read more about when to use each?