Member Since 4 Years Ago

Experience Points
16,790
Total
Experience

3,210 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
150
Lessons
Completed
Best Reply Awards
2
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.

  • Community Pillar

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

Level 4
16,790 XP
May
21
3 weeks ago
Activity icon

Replied to Facebook Login (URL Blocked)

Have the same issue, any suggestions?

May
16
3 weeks ago
Activity icon

Replied to Test User Controller And Recive Bad Verify Email Url

Check your .env file in the APP_URL key, should be changed to use the specific port you're on:

APP_URL=http://localhost:8000

Activity icon

Replied to How To Install Node_module?

That is not an error, is the output of npm install, you should see a node_modules folder in the root of your project.

May
13
4 weeks ago
Activity icon

Replied to Array Of Dynamic Dependent Select Box In Vue.js

Explicitly pass the institute.id thru the @change="onChangeUniversity(institute.id)" method.

Activity icon

Awarded Best Reply on How To Accept Requests On Invokable Controllers?

The example has a <form> element which indicates that you'll need to send it thru a POST endpoint:

In routes/web.php or if using API's in routes/api.php:

<?php

Route::post('route/to/action', InvokableController::class)->name('route.name');

Controller:

<?php

namespace .....;

use Illuminate\Http\Request 

class InvokableController extends Controller 
{
		public function __invoke(Request $request)
		{
				dd($request->abilities);
		}
}

Hope it helps.

May
12
1 month ago
Activity icon

Replied to How To Select The Data From The Many-to-many Relationship Table That Matches The Desired Value?

Try

$model->mainchallengecategories()->where('column', $mainchllengecategories)->get();

But in the User model roles function you're passing a 'role' string which I think it should be the foreign key od that belongs to the User which is role_id.

Activity icon

Replied to Backslashes On URL With API Resources

Try returning the Resource alone without the response function:

return new UserResource($user) I think that should do it.

Activity icon

Replied to Jetstream Admin Users

I think there are many ways to do this depending on how you want to structure things around, but a common way I've seen that does not involve foreign keys or extra configuration is adding a config file and specifying the email of admin's email in a key inside the config file, just check of the user's email is there and add policies checking that.

I'm assuming that's something you could do since you mention that every user that registers is a standard user. You'll still have to register the user but you avoid issues that FK will throw like querying the DB each time it loads.

If Jetstream can do that it will still a way to add the "type" on registration.

It's just another option.

Activity icon

Replied to Fatal Error: Call To Undefined Method ComposerAutoloaderInit ::getLoader()

Could be that is being cached. Try: php artisan optimize:clear, then dump autoload again to clear everthing. I'll suggest that you delete the vendor folder, the composer.lock before the commands. Or you could event try cloning the project again and reinstalling.

Activity icon

Replied to How To Accept Requests On Invokable Controllers?

The example has a <form> element which indicates that you'll need to send it thru a POST endpoint:

In routes/web.php or if using API's in routes/api.php:

<?php

Route::post('route/to/action', InvokableController::class)->name('route.name');

Controller:

<?php

namespace .....;

use Illuminate\Http\Request 

class InvokableController extends Controller 
{
		public function __invoke(Request $request)
		{
				dd($request->abilities);
		}
}

Hope it helps.

May
10
1 month ago
Activity icon

Awarded Best Reply on Writing Tests On Multiple Guards

My approach would be to first know if all those guards can do the action, if they can I would just test that I can perform the action without worrying about the guard. But if some guards can perform the action and other don't then I would create a request per guard probably in the same test or creating a separate test for all.

Probably like this:

public function authorized_user_can_access_an_address()
    {
        $this->actingAs(User::factory()->create(['role' => 'vendor']), 'vendor'));

        $address = Address::factory();

        $response = $this->getson('route/to/action'));
        $response->assertOk();

		// You can even test the content of the response:
        $response->assertJson([
            'data' => [
                [
                    'id' => $address->id,
                    'user_id' => $address->user->id,
					// ...
                ]
            ]
        ]);
    }

Not sure if this is what you're looking for, hope it helps.

May
09
1 month ago
Activity icon

Replied to Writing Tests On Multiple Guards

My approach would be to first know if all those guards can do the action, if they can I would just test that I can perform the action without worrying about the guard. But if some guards can perform the action and other don't then I would create a request per guard probably in the same test or creating a separate test for all.

Probably like this:

public function authorized_user_can_access_an_address()
    {
        $this->actingAs(User::factory()->create(['role' => 'vendor']), 'vendor'));

        $address = Address::factory();

        $response = $this->getson('route/to/action'));
        $response->assertOk();

		// You can even test the content of the response:
        $response->assertJson([
            'data' => [
                [
                    'id' => $address->id,
                    'user_id' => $address->user->id,
					// ...
                ]
            ]
        ]);
    }

Not sure if this is what you're looking for, hope it helps.

Activity icon

Replied to How To Create Factories When Using Model Events?

Hi chaudigv thank you for replying, unfortunately it didn't work for me, I receive this error:

SQLSTATE[23000]: Integrity constraint violation: 19 NOT NULL constraint failed: businesses.owner_id which doesn't receive because of the Model event method assigning the FK to the businesses: self::creating(fn ($business) => $business->owner_id = auth()->id()); using withoutEvents() method in the test doesn't work either, so I must be signed in even if I don't care if the Business is from the signed in user so I need to sign in and sign out to create a Business which of course sucks. I appreciate any insight thanks again.

May
03
1 month ago
Activity icon

Replied to Disregard Thread

True that, my apologies and thanks for the advice.

Activity icon

Replied to 'SQLSTATE[42804]: Datatype Mismatch: 7 ERROR: Column "active" Is Of Type Boolean But Expression Is Of Type Integer

You could always cast the active column to a boolean in your Model.

	protected $casts = ['active' => 'boolean'];
Activity icon

Started a new Conversation How To Create Factories When Using Model Events?

Context:

* BusinessFactory
* BusinessesTest
* Models/Business

How can we use a ModelEvent when using factories? if there's a column that we want to update in an Event and there's a relationship depending on the Model for example owner_id in Business model which is updated in ModelEvent and assigning the auth user to the FK.

Test

	/**
     * @test
     * @throws \Throwable
     * @endpoint ['GET' => '/api/businesses']
     * @only ['authenticated']
     */
    public function authenticated_user_can_get_all_businesses()
    {
        // $this->fakeEvent();

        $business = Business::factory()->create();
        $this->actingAs(User::factory()->create());

        $response = $this->getJson(route('business.index'));
        $response->assertOk();
        $response->assertJson([
            'data' => [
                [
                    'id' => $business->id,
 					'owner_id' => $business->owner->id
                    'name' => $business->name,
                ]
            ]
        ]);
    }

ModelEvent

<?php

namespace App\Models;

class Business extends Model 
{

	public static function boot() 
	{
		self::creating(fn ($business) => $business->owner_id = auth()->id());
	}		

}

BusinessFactory definition

	public function definition()
    {
        return [
            'name' => $name = $this->faker->unique()->company,
            'owner_id' => User::factory(),
	}

So when triggering the test it will fail because the Business doesn't have an owner_id key right? and the only way so far is disabling Events so it will use the User ID from the Factory but in case of using seeders or any other way of faking the data it will throw errors due to the FK not being created because the factory is not receiving the auth()->id().

My question is: How do you harmonitize Factories FK and ModelEvents? if that makes sense. Thanks in advance.

May
02
1 month ago
Activity icon

Started a new Conversation Disregard Thread

Disregard:

Needed to see how slugs are handled in case of a duplication, (need a delete btn on threads)