briankidd

briankidd

Member Since 5 Years Ago

Lynchburg VA

Experience Points
70,410
Total
Experience

4,590 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
837
Lessons
Completed
Best Reply Awards
11
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
70,410 XP
Aug
14
2 months ago
Activity icon

Awarded Best Reply on Opinions On Package To Deal With Recurrences

I've used this one and had no issues: https://github.com/simshaun/recurr

Activity icon

Awarded Best Reply on Dispatch Delayed Job Before It's Programmed Time

@franciscool004 A different approach but, if you have the delivery time in the orders table, why not just run a job every minutes looking for orders that are scheduled to be delivered within 10 minutes (this could be a configuration setting) and then create the job and dispatch? If they pick up early, trigger it on demand.

This is one reason I don't delay jobs very much. If something needs to change later, you've got to find some way to get a handle on the job.

Activity icon

Replied to Dispatch Delayed Job Before It's Programmed Time

@franciscool004 A different approach but, if you have the delivery time in the orders table, why not just run a job every minutes looking for orders that are scheduled to be delivered within 10 minutes (this could be a configuration setting) and then create the job and dispatch? If they pick up early, trigger it on demand.

This is one reason I don't delay jobs very much. If something needs to change later, you've got to find some way to get a handle on the job.

Activity icon

Replied to Defining How Models Are Serialized When In A Relationship

@mboynes, you can pass an array with a closure to with:

User::with(['related_model' => function($query){
  $query->without('user');
})->get();

$query is an instance of the QueryBuilder for the related_model

Activity icon

Replied to Get Real With Laravel Echo / Broadcasting

@ivanradojevic This looks okay but you may want to try add some public properties to your event class.

Activity icon

Replied to UpdateOrCreate And WhereIn

@shavonn You should be able to do:

Document::whereIn('document_type', $doc_types_share)->updateOrCreate ...
Activity icon

Replied to How Do I "ssh Into Sites Directory"?

@maparfitt you can ssh using:

ssh -i <path to your private key> [email protected]<server ip address>

Once you are in, you'll be in the /home/forge directory. You can then cd into the site directory using:

cd <your site>

This may be unrelated but seeing .env worried me. Hopefully you know you shouldn't commit .env to your source code - your environment variables can be manage in Forge by selecting your site and then "Environment" in the left navigation.

You need to cd into your site/project and then run the git command.

Aug
12
2 months ago
Activity icon

Awarded Best Reply on Pass Variables To @include

Is mytemplate a blade file or vue component? I’m assuming it’s a blade file since you are using @include - am I correct?

Aug
11
2 months ago
Activity icon

Replied to Pass Variables To @include

Is mytemplate a blade file or vue component? I’m assuming it’s a blade file since you are using @include - am I correct?

Aug
10
2 months ago
Activity icon

Replied to Every User Is Automatic Logged In To Nova

Is the app environment set to local? All users are allowed in the local environment.

Aug
08
2 months ago
Activity icon

Awarded Best Reply on Enum Package To Choose

@boskiv I’ve used the BenSampo package on several projects and it worked great for me. With that said, you can rarely go wrong with a spatie package so I think you will be happy with either of these.

Aug
02
2 months ago
Activity icon

Awarded Best Reply on Generating Menu

Activity icon

Replied to Dynamic Tab Change On Form Submit In Vue.js

@tarang19 I can’t quite follow your code but generally, I just keep track of the activeTab in the data rather than a Boolean isActive. How do you know what isActive corresponds to?

Activity icon

Replied to Option Value Not Visible In Select2 Dropdown

@noblemfd Have you tried adding a value to that option? Something other than an empty string?

Activity icon

Replied to Eloquent Filtering The Many To Many Relationship On 3rd Level

@amitshahc I would probably add a model that represents enquiries_shops and work with it. See this documentation: https://laravel.com/docs/7.x/eloquent-relationships#defining-custom-intermediate-table-models

Jul
26
2 months ago
Activity icon

Awarded Best Reply on User Fields Exposed Publicly Or Not?

@crugg The view gets processed on the server so the user won’t see that unless you explicit render the data. If you are returning a model in response to an AJAX request, all of the model will be serialized except fields that are in the $hidden property on the model. If you look at the Laravel default User model, you should see the hidden property set to an array of fields such as password, etc.

You can also use the select method to define the fields you want: User::where(‘name’, $username)->select(‘name’, ‘email’)->first().

Activity icon

Replied to User Fields Exposed Publicly Or Not?

@crugg That default code in the api routes is for getting data about the current user. That’s returning JSON so the $hidden model property will be considered. If you are adding sensitive data to your user model, be sure to add those fields to the $hidden property.

Activity icon

Replied to Enum Package To Choose

@boskiv I’ve used the BenSampo package on several projects and it worked great for me. With that said, you can rarely go wrong with a spatie package so I think you will be happy with either of these.

Activity icon

Replied to Google Recaptcha 3 Error Secret Key Is Invalid

@hadayat Have a look at this tutorial, straightforward and worked for me. I’m assuming your issue is related to building up the url, etc. provided you are using the correct secret.

https://codeforgeek.com/google-recaptcha-v3-tutorial

Activity icon

Replied to How To Restore Using Eloquent, With An Api With React? With Softdeletes

@joshsalway This is personal preference as to how to handle it. I agree I don’t particularly like a method doing multiple things. You could add another method to your current controller for restoring soft deleted models or another option is to create a CustomerRestoreController and have the update method there for explicitly restoring the customer.

Activity icon

Replied to Laravel Forge Support?

@ranx99 I would assume that your message is in the queue and they will respond but I don’t think they have weekend hours. If this is urgent, I’m sure you’ve exhausted all your options such as resetting password, etc. Sorry I’m not much help on this one.

Activity icon

Replied to User Fields Exposed Publicly Or Not?

@crugg The view gets processed on the server so the user won’t see that unless you explicit render the data. If you are returning a model in response to an AJAX request, all of the model will be serialized except fields that are in the $hidden property on the model. If you look at the Laravel default User model, you should see the hidden property set to an array of fields such as password, etc.

You can also use the select method to define the fields you want: User::where(‘name’, $username)->select(‘name’, ‘email’)->first().

Jul
25
3 months ago
Activity icon

Replied to Download Multiple Files Dompdf

@msslgomez put as much logic in the handle method that makes sense but you can always add other methods to the job if needed for clarity.

Activity icon

Replied to View Redis Queue Jobs List

@rvkvino you need to determine why supervisor is stopping - that’s the whole purpose of supervisor is to ensure things are running. Did you follow the documentation for supervisor?https://laravel.com/docs/7.x/queues#supervisor-configuration

Activity icon

Replied to How To Identify User Via API

@jamols09 if you’re using the default Laravel auth, the user will be available to you in the controller using Auth::user(), auth()->user(), or on the request, request()->user().

Jul
20
3 months ago
Activity icon

Awarded Best Reply on Don't Know How To Retrieve Values From Listener Inside A Blade

@acrm if I’m understanding your schema based on the migrations, it seems your model Logging modules and activities should both be a belongsTo relationship (would be better if the methods were singular since it’s a belongsTo) and on Loggingmodules and Loggingactivity, the logs should be hasMany. Have a look at the docs: https://laravel.com/docs/7.x/eloquent-relationships#defining-relationships

Activity icon

Awarded Best Reply on Laravel Spark Action Quota

@smurfiez Create a new Stripe controller and extend the base one: \Laravel\Spark\Http\Controllers\Settings\Billing\StripeWebhookController

override the method handleInvoicePaymentSucceeded (or teamInvoicePaymentSucceeded if using team billing) and include the same logic but add your logic to reset the limit.

This controller handles all of the webhooks so find the appropriate method to handle a plan change.

To preselect, add query string plan={plan_id}

Jul
19
3 months ago
Activity icon

Replied to Don't Know How To Retrieve Values From Listener Inside A Blade

@acrm if I’m understanding your schema based on the migrations, it seems your model Logging modules and activities should both be a belongsTo relationship (would be better if the methods were singular since it’s a belongsTo) and on Loggingmodules and Loggingactivity, the logs should be hasMany. Have a look at the docs: https://laravel.com/docs/7.x/eloquent-relationships#defining-relationships

Activity icon

Replied to Don't Know How To Retrieve Values From Listener Inside A Blade

@acrm what is the issue? The subject is about an event listener but you are writing about model relationships.

Activity icon

Replied to How To Create A Model Relationships And Resource For Below Structure

@sekar_dev_14 Yes, I'm assuming you have some categories/subs that are available for all users and only an admin can change those. If any user can change global categories/subs, my suggestion won't work.

Activity icon

Replied to Fetch Model's Nested Relationship Data

As @snapey suggested, you should log the queries. Also, have use tried switching the User and Customer where the Customer hasOne User and the User belongs to Customer?

Jul
18
3 months ago
Activity icon

Replied to Fetch Model's Nested Relationship Data

@kkhicher1 can you show us your customer and user models? Thanks

Activity icon

Replied to How To Create A Model Relationships And Resource For Below Structure

@sekar_dev_14 I went back and looked at the diagram. Let me suggest that you keep the category_parent and category_sub and remove cat_user_parent and cat_user_sub.

Change category_parent and category_sub to have a nullable user_id field. When a user creates a category_parent or category_sub, set the user_id based on the authenticated user.

Then, on the user, you can have these:

public function categoryParents()
{
  return $this->hasMany(CategoryParent::class);
}

public function categorySubs()
{
  return $this->hasMany(CategorySub::class);
}

If you need to display all category parents ('global' category parents and category parents belonging to the current user), you could create a query scope (https://laravel.com/docs/7.x/eloquent#local-scopes) on the User model like this:

public function scopeAllCategoryParents($query)
{
  return $query->where('user_id', null)->orWhere('user_id', $this->id);
}

public function scopeAllCategorySubs($query)
{
  return $query->where('user_id', null)->orWhere('user_id', $this->id);
}

that you can then use like this (notice the 'scope' prefix is not needed):

$user->allCategoryParents()->get();
// or
$user->allCategorySubs()->get();

Hope this helps.

Activity icon

Replied to Download Multiple Files Dompdf

@msslgomez No, doesn't matter. I've used this package but there are plenty of others: https://github.com/Ne-Lexa/php-zip

Jul
17
3 months ago
Activity icon

Replied to Preventing A Post From Being Created In Case A Validation Fails

@janmoes What else are you doing with "validatedData()"? You should just check the translation to ensure it is valid before creating the post.

Is the if condition just checking for the existence of data and not that the data is actually valid? Not following what you are doing here.

Activity icon

Replied to Download Multiple Files Dompdf

@msslgomez I'm sorry, I don't know what you are asking. When you have multiple files, you'll need to either download a zip or give them a link where they can download themselves. With a slow process, I'd prefer sending a link once it is finish but that's a personal decision.

Activity icon

Replied to Unserialize Only Works If Model Boot And Booted Retrieved Event Is Added.

All you need to do is set the $casts property on the model and it handles the serialization for you:

protected $casts = [
  'data' => 'array'
];

https://laravel.com/docs/7.x/eloquent-mutators#array-and-json-casting

Activity icon

Replied to Laravel Spark Action Quota

@smurfiez Create a new Stripe controller and extend the base one: \Laravel\Spark\Http\Controllers\Settings\Billing\StripeWebhookController

override the method handleInvoicePaymentSucceeded (or teamInvoicePaymentSucceeded if using team billing) and include the same logic but add your logic to reset the limit.

This controller handles all of the webhooks so find the appropriate method to handle a plan change.

To preselect, add query string plan={plan_id}

Activity icon

Replied to How To Create A Model Relationships And Resource For Below Structure

@sekar_dev_14 Have a look at the Laravel Relationships documentation (https://laravel.com/docs/7.x/eloquent-relationships), it's very good. We're willing to help you but you need to make an effort so we'll have something to work with.

Activity icon

Replied to Can T Acess External API

@johnconnet Have you verified this works using an HTTP client, like Postman? Start there and ensure it's working then come back to your code. Not knowing that endpoint, I'm not sure what else to suggest.

Activity icon

Replied to Unserialize Only Works If Model Boot And Booted Retrieved Event Is Added.

@albertvds Exactly what are you trying to do? Is "data" suppose to be an array/json? It may be another way to meet your need but I need more information.

Activity icon

Replied to Download Multiple Files Dompdf

@msslgomez There are several ways to do this and I'll suggest what I'd probably do. There are others on the forum that may have other ideas.

For certain, I wouldn't try to do this all at one time. It would be better to do something like this asynchronously and not make the user wait.

First of all, I assume the logic you are using to get the data needed from the database is optimized - I had a difficult time trying to follow it. If you are not sure, I would use something like the Debugbar to see what is taking so long. My guess is that it's querying the data and not so much for the PDF creation.

Here's what I would do:

Loop through the parameters needed for each report and create a separate job for each. You'll want to have some way to keep track of the jobs and if they have all completed. You could use job chaining (https://laravel.com/docs/7.x/queues#job-chaining) or Mohammed Said just did a talk this week on queues and using Laravel Bus that you may find helpful: https://youtu.be/ajDwUNfKu48?t=2451

At a high level, create a job for each report and save the report in a new directory. After the pdf jobs are complete, dispatch another job that is responsible for creating a zip file of all of the reports. If you do this on a public directory or an S3 bucket (if the S3 resource is private, you'll need to use a signed url), you can then email a link to the zip file to the user where they can download it.

Hope this helps.

Activity icon

Awarded Best Reply on Is This A Good Practice Or Not?

@joaquinvilchez I think I know what you're asking. You definitely need to store the price of the product on the order itself. Typically, an order can have multiple line items so, if this is true in your case, you should have a order line items table too. I would capture the product price at the time the order/line item is created. It's fine to have the temporary prices table for auditing purposes but the product price should be stored in relation to the order.

Hope this helps.

Activity icon

Replied to Is This A Good Practice Or Not?

@joaquinvilchez I think I know what you're asking. You definitely need to store the price of the product on the order itself. Typically, an order can have multiple line items so, if this is true in your case, you should have a order line items table too. I would capture the product price at the time the order/line item is created. It's fine to have the temporary prices table for auditing purposes but the product price should be stored in relation to the order.

Hope this helps.

Jul
14
3 months ago
Activity icon

Replied to Laravel Echo Does Not Listen For Public Channel Events ?

You have to listen for the event name, like this: .listen('MySocketEvent')...

See an example here: https://laravel.com/docs/7.x/broadcasting#using-example-application

If you're overwriting how it's broadcasted, you may need to take the . off the beginning of 'test' but I'm not sure.

Activity icon

Replied to Advanced Format Of Laravel Excel Maatwebsites For Export

If you have all of the correct data from your database, as much as I like Laravel Excel, it doesn't provide a way to use a template. What you should do is create an xlsx file with all of the formatting and use a library that lets you open the file, write to it, and then save as a new file.

I think you can do this with PhpSpreadsheet and there are probably others. Last thing I read from Laravel Excel was that using a template is on the roadmap but they don't have a date as to when this will happen.

Good luck.