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

deansatch

deansatch

Member Since 3 Years Ago

Experience Points
74,010
Total
Experience

990 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
327
Lessons
Completed
Best Reply Awards
57
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 15
74,010 XP
Nov
20
5 days ago
Activity icon

Awarded Best Reply on Laravel Event Subscriber Error

If it works on local and production, where is it not working? It looks like that eloquent query is not returning a result, or it is not returning a result with an orderProduct. So you need to debug your query and make sure for that record the data is in the database.

Steps I would take (assuming this is one item and not part of a loop):

  • dd($pharmacyEvent->prescription->product_id)
  • check that record is in the database and has all relevant relations
  • dd($stock)
  • comment out the whereHas() and the whereNull() parts of the query
  • add those in one by one

That should hopefully highlight the issue

Nov
19
6 days ago
Activity icon

Replied to User Factory Has Relation Only If User Type = X

ah never mind...I changed it slightly and it worked...


  public function configure()
    {
        return $this->afterMaking(function (User $user) {
           
        })->afterCreating(function (User $user) {
            $user->posts()->save(Post::factory()->make());
        });
    }

Activity icon

Replied to User Factory Has Relation Only If User Type = X

It's in my original post. ^ That is the seeder.

User has many posts.

The user factory:


public function definition()
    {
    
        return [
            'name' => $name,
            'type' => $this->faker->randomElement(['author', 'client']),
        ];
    }

So basically trying to do this:


$user = User::factory()
->times(1000)
// if($user->type == 'author')
->has(Post::factory(), 'posts')
// endif
->create()


I tried adding this to my UserFactory but got "unable to locate factory for App\Post:


    public function configure()
    {
        return $this->afterMaking(function (User $user) {
           
        })->afterCreating(function (User $user) {
            $user->posts()->save(factory(Post::class)->make());
        });
    }


Activity icon

Replied to User Factory Has Relation Only If User Type = X

Not really sure how though

Activity icon

Started a new Conversation User Factory Has Relation Only If User Type = X

If I have a UserFactory with a random selection of user types, how can I write this so that it creates 1000 users, but only users with $user->type == 'author' will have a post created.

As it stands, every user gets a post which isn't ideal.


User::factory()->times(1000)->has(Post::factory(), 'posts')->create()


Activity icon

Replied to CSV League - Expecting Array Got Object

Looks like you need to fetch the db results:

$query = DB::connection('reporting')->select('
            select * from users
        ')->get();
Activity icon

Replied to Laravel Event Subscriber Error

If it works on local and production, where is it not working? It looks like that eloquent query is not returning a result, or it is not returning a result with an orderProduct. So you need to debug your query and make sure for that record the data is in the database.

Steps I would take (assuming this is one item and not part of a loop):

  • dd($pharmacyEvent->prescription->product_id)
  • check that record is in the database and has all relevant relations
  • dd($stock)
  • comment out the whereHas() and the whereNull() parts of the query
  • add those in one by one

That should hopefully highlight the issue

Activity icon

Replied to Won't Let Me Log In After Changing Password

Try dd($request->nyttpassord) after your save() to make sure that what you are typing is actually what is being stored

Nov
12
1 week ago
Activity icon

Started a new Conversation Seeding Nested Relationship With Factory

This is what I'm trying to do...

Company::factory()
            ->times(300)
            ->has(Branch::factory()->carParks(), 'branches')
            ->create();

in my BranchFactory I have...

public function carParks()
    {
        return $this->afterCreating(function (Branch $branch) {
            CarParkFactory::new()->template()->create([
                'branch_id' => $branch->id,
            ]);
        });
    }

And in CarParkFactory ...

 public function template()
    {
        return $this->state(function () {
            return [
                    'name' => 'car park 1',
            ];
        });
    }

This all works well. i.e. it creates the companies, each with a branch, and each branch has a car park named 'car park 1'. But I actually want each branch to have 4 car parks with 4 different set names (car park 1, car park 2, car park 3 and car park 4)

How could I do this? Please bear in mind I've simplified this to keep the code short. The reality is each car park will have more fields than just a name.

Nov
11
2 weeks ago
Activity icon

Started a new Conversation Sanctum Still Sees Auth() As Main User When Impersonating

I have an impersonate user feature which basically does:

\Auth::onceUsingId($request->session()->get('impersonate'));

This all works fine in general i.e. if I impersonate a user and dd(auth()->user()) it returns the impersonated user. However, any endpoints that are fetched via the api with auth:sanctum return the master user instead of the impersonated user. Is there something I need to run when starting/stopping impersonation e.g. refresh sanctum key somewhere?

This is all a single domain, self consumed api, totally relying on normal auth session.

Thanks

Oct
13
1 month ago
Activity icon

Replied to Video Memory Leak In Chrome

Yeah I watch videos on loads of other sites but this one just kills my laptop. To the point where I have to slowly position my mouse over the close tab button and click it then come back 5 minutes later to see if the tab is gone and I can take back control

Activity icon

Replied to Video Memory Leak In Chrome

Was that dev tools open in the same tab as the video or just another tab. I most likely have it open on another tab but not in laracasts

Activity icon

Started a new Conversation Video Memory Leak In Chrome

I can’t be the only one that has been unable to watch a laracast video for over 6 months due to the fact that some sort of memory leak freezes my whole MacBook Pro within 3 minutes of playback??

Mbpro 2018 (top spec) Latest chrome Latest OS

Disclaimer: I still watch the videos on my phone

Oct
07
1 month ago
Activity icon

Awarded Best Reply on How To Save Array With Foreach?

auth()->id()[$key] This.

auth()->id() will return the logged in users id. What you currently have will return null

Activity icon

Replied to Laravel Validation

Just looking at it, I doubt you actually meant to have these in your validator:


 'user_id' => 'required',
 'uuid' => 'required',

  'to' => 'required',
'from' => 'required',

'isConfidential' => 'required',
'files' => 'required'

Activity icon

Replied to Laravel Validation

Failed in what way?

Activity icon

Replied to How To Save Array With Foreach?

auth()->id() still returns user id...it just shouldn't have an array key stuck on the end

Activity icon

Replied to How To Save Array With Foreach?

auth()->id()[$key] This.

auth()->id() will return the logged in users id. What you currently have will return null

Activity icon

Replied to Laravel Has A Security Hole

what? You do realise you've posted up enough information in those screenshots for anyone to log into the site? Edit your original post, take it down and change ALL passwords

Activity icon

Replied to Laravel Has A Security Hole

describe the situation in more detail. Also, if that is your actual production .env file and database, please remove the screenshot and change all login credentials

Activity icon

Replied to Laravel Has A Security Hole

If you give them your .env file then probably yes. But how would they get it? Where is the security hole you speak of?

Sep
08
2 months ago
Activity icon

Started a new Conversation Can’t Search Forum On A Phone

The search function only works on the videos on iPhone safari. No way to search the forum. Not sure if it is intentional though