deansatch

Member Since 4 Years Ago

Experience Points
78,190
Total
Experience

1,810 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
344
Lessons
Completed
Best Reply Awards
60
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 16
78,190 XP
Apr
16
1 day ago
Activity icon

Replied to Very Very Slow Api Requests On Homestead

Yeah, that’s what I’m trying to figure out. My vm is pretty high spec and certainly shouldn’t struggle to make a post request. Wondered if it might be some weird homestead thing that needs a tweak

Activity icon

Replied to Very Very Slow Api Requests On Homestead

on an azure server

Activity icon

Replied to Very Very Slow Api Requests On Homestead

thing is, other api calls are ok - just seems to be the azure ones

Activity icon

Started a new Conversation Very Very Slow Api Requests On Homestead

Does anyone know why an api call to Azure would take 20 seconds to return a response on homestead but when I push to production server it is almost instant?

Apr
06
1 week ago
Activity icon

Replied to N+1 Issue

Not sure of your relationship setup but I think you may not actually be eager loading as you think. Try this...


$payment = Payment::with(['expense_reports.expenses' ])

Mar
06
1 month ago
Activity icon

Awarded Best Reply on Livewire Not Working

Also try publishing assets if you haven’t already

php artisan livewire:publish --assets

Activity icon

Awarded Best Reply on Livewire Do Not Show The Data With Out The Page Reload

I’m on my phone at the minute so can’t really type loads of code. It isn’t really a livewire thing, if you know php and/or laravel you can do it. I think you can just add $comment = Comment::create...

Then array_push($this->comments, $comment)

Mar
05
1 month ago
Activity icon

Replied to Mass Assignment Query

Just spotted the user_id - the first answer @michaloravec gave is better than mine

Activity icon

Replied to Mass Assignment Query

Page::create($request->all()); but you really should validate and then do Page::create($validated);

You can also append to $validated before you create: $validated[‘uri’] = Str::slug($request->input('title'), '-');

Activity icon

Replied to How To Get To Tenants Data Throw Central Admin Panel ?

tenancy()->initialize($tenant); then run your tenant code

$tenant is the desired tenant model eg Tenant::find(‘my tenant’)

When you are done tenancy()->end() to switch back to central

Activity icon

Replied to Livewire Not Working

Also try publishing assets if you haven’t already

php artisan livewire:publish --assets

Activity icon

Replied to Livewire Not Working

Maybe a daft question but what version of laravel is this?

Activity icon

Replied to Livewire Do Not Show The Data With Out The Page Reload

I’m on my phone at the minute so can’t really type loads of code. It isn’t really a livewire thing, if you know php and/or laravel you can do it. I think you can just add $comment = Comment::create...

Then array_push($this->comments, $comment)

Activity icon

Replied to Livewire Do Not Show The Data With Out The Page Reload

This will work but means you are querying all comments every time. You only need to add the new comment to the existing var

Activity icon

Replied to Livewire Do Not Show The Data With Out The Page Reload

After creating the comment you need to push the new comment onto your $this->comments array

Activity icon

Replied to Livewire Not Working

I agree with tykus about the mount(). No need to keep querying the database for the skills.

Assuming your code provided was complete, you need to wrap your livewire blade code in a div otherwise expect unexplained nothingness

Mar
04
1 month ago
Activity icon

Replied to Re-use QueryScope As Attribute

Happy to use the scope in the query so long as I can still retrieve all the results - this is where I thought that during the query the scope could be used in a subquery to set a custom 'overdue: bool' property on each result.

Feels a bit wrong repeating a lot of logic, one for a scope and one for the accessor

Activity icon

Replied to Re-use QueryScope As Attribute

Just wondered if the scope could somehow be reused on the collection or if it can set a custom attribute like withCount()

Activity icon

Started a new Conversation Re-use QueryScope As Attribute

I have a pretty complex query scope scopeIsOverdue. I also need a getIsOverdueAttribute. Is there a way I can reuse the query scope for this rather than try and mimic the scopes logic again

The query scope will limit the results to just the overdue ones. I want to be able to still show all results but have a way to also identify an overdue row

So basically:

$results = Model::query()->isOverdue() returns only overdue results (currently works)

$results = Model::all() returns all results (currently works)

Then I want to be able to do something along the lines of....

$results->first()->isOverdue() Should be true or false (or 0 or 1)

Mar
03
1 month ago
Activity icon

Awarded Best Reply on Validate Field :: Error Message Not Appearing In View

Try

@error('capcha') {{$message}} @enderror

Activity icon

Replied to Issue With Laravel Policy

I am sure I remember reading something in the spatie docs about avoiding naming a permission the same as a policy, so if you have a permission called “create” and a policy of the same name it will cause issues

Activity icon

Replied to Transaction Not Working As Expected

It does run the insert() on both examples though, just not the delete(). Wondering if it has to be a separate transaction per 'transaction'? If that is the case, I don't want to commit the delete unless the insert has worked

Mar
02
1 month ago
Activity icon

Started a new Conversation Transaction Not Working As Expected

When I run this, fees are inserted but the delete is ignored

DB::beginTransaction();
        try {
            $this->fees()->delete();
            Fee::insert($data);
            DB::commit();
        } catch (\exception $ex) {
            DB::rollback();
        }

When I run this, it works as expected i.e. deletes all fees, then inserts new ones

$this->fees()->delete(); //moved outside of transaction

DB::beginTransaction();
        try {
            Fee::insert($data);
            DB::commit();
        } catch (\exception $ex) {
            DB::rollback();
        }

What am I missing? I don't really want it to delete anything if the insert fails

Feb
23
1 month ago
Activity icon

Replied to 2 Laravel Apps Sharing Login

that looks good - just wondering now as I just realised I will probably want separate php versions for each laravel install if I host them on two completely separate servers and use database sessions, can I still do this. Maybe have to resort to the subdomain though

Feb
22
1 month ago
Activity icon

Replied to 2 Laravel Apps Sharing Login

Yes, digital ocean and nginx. I don't want to use a subdomain if I can help it.

Activity icon

Replied to 2 Laravel Apps Sharing Login

Thanks. So if I run it in a subdirectory, would the session just work across both copies without the need to change anything config-wise?

Do you know how I would go about making the subdirectory version?

Activity icon

Replied to 2 Laravel Apps Sharing Login

there will only be one login form and that is on the main app. The thing I want to ensure is that the logged in session persists across both apps. Also, can I run a second copy of laravel on the same domain in a subdirectory?

Activity icon

Started a new Conversation 2 Laravel Apps Sharing Login

I have a large app on 5.1 and have to build a large additional section which I want to do in v8 as upgrading the whole thing isn't possible at the moment. The plan is to build the additional section to read from the same database but it needs to be behind the same login i.e. login on main app also logs you in on the v8 part.

Happy to put both on the same server but would be nice if that wasn't a requirement.

Couple of questions...

  1. is it possible to run a second version of laravel on the same domain in a subdirectory? e.g. domain.com/laravel-v2/*
  2. how can I share the login?

Thanks

Feb
19
1 month ago
Activity icon

Replied to Conditional Renderng Wire:click

Give more context, show more code and tell us what you mean by “not working”.

I suspect what you probably need to do is lose the condition altogether and use form validation instead inside your live wire controller. That is assuming you don’t want the form to submit unless a gdpr checkbox has been ticked?

Activity icon

Replied to How To Pass Array As Second Parameter In Livewire Function

It JS, you need to implode it then explode within your controller

Activity icon

Replied to Filesystems.php - Read Only?

I've never actually used it myself but if you were to store 3 files with the above config on local driver:

Storage::put('secret.txt', 'hello', 'private');; // file created will be read/write but no access for guests/everyone

Storage::put('web.txt', 'hello', 'public');; // file will be read/write but readonly for guests/everyone

Storage::put('read.txt', 'hello', 'readonly'); // file created will be readonly

Activity icon

Replied to Getting Stancl/tenancy Working Per Domain In Homestead

could you try a tenant with a .test extension? I think its just the .localhost that is causing the issue

Activity icon

Replied to Getting Stancl/tenancy Working Per Domain In Homestead

so, domains are set up in hosts file, and yaml file, and your central database 'domains' table shows both of those domains, and both tenant tables exist and have migrated? If so and it still isn't working you might need to check your log files to find the cause

One thing to consider...I'm not so sure you can use localhost as a domain extension - I would try something like foo.test and bar.test as your tenant domains - I get the same error as you if I try and visit foo.localhost but foo.anythingelse gives a completely different error

Activity icon

Replied to Getting Stancl/tenancy Working Per Domain In Homestead

Did you reload homestead server to pick up the changes?

vagrant reload --provision

Activity icon

Replied to Getting Stancl/tenancy Working Per Domain In Homestead

ah sorry, yes you do need to add them to your yaml file.

        map: ats.test
        to: /home/vagrant/code/public
        map: foo.localhost
        to: /home/vagrant/code/public
        map: bar.localhost
        to: /home/vagrant/code/public

Activity icon

Replied to Getting Stancl/tenancy Working Per Domain In Homestead

No, just the hosts file. Did you check that the databases have been created for the tenants and the domains are definitely correct?

Activity icon

Replied to Filesystems.php - Read Only?

I think you can add a custom permission level...

https://laravel.com/docs/8.x/filesystem#local-files-and-visibility

'dir' => [
            'public' => 0775,
            'private' => 0700,
            'readonly' => 0444,
        ],
Activity icon

Replied to Getting Stancl/tenancy Working Per Domain In Homestead

You just add them to your hosts file too on the same ip


192.168.10.10           ats.test
192.168.10.10           foo.localhost
192.168.10.10           bar.localhost

Dec
16
4 months ago
Activity icon

Replied to Mailhog On Staging With Auth?

Simple but effective!

Activity icon

Started a new Conversation Mailhog On Staging With Auth?

Does anyone know a good way of using mailhog with laravel on a staging server and making it password protected so the client can freely test out an app without worrying about using real email addresses but still be able to read the emails that it sends out?

Dec
07
4 months ago
Activity icon

Started a new Conversation Order By Date Desc Time Asc

Is there an elqouent way to order by date and time separately. e.g. created_at order by date desc, time asc

Nov
20
4 months 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
4 months 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