briankidd

briankidd

Member Since 5 Years Ago

Lynchburg VA

Experience Points
62,130
Total
Experience

2,870 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
780
Lessons
Completed
Best Reply Awards
7
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 13
62,130 XP
Aug
02
3 days 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
1 week 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
1 week 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
2 weeks 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
2 weeks 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
2 weeks 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
2 weeks 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 weeks 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.

Jun
18
1 month ago
Activity icon

Awarded Best Reply on Mail Importance

You can get a reference to the SwiftMessage in the mailable like this:

public function build()
{
  return $this->withSwiftMessage(function ($message) {
    $message->setPriority(\Swift_Message::PRIORITY_HIGH);
  })-> ... do other stuff;
}
Jun
16
1 month ago
Activity icon

Replied to Help Output By Month

I like the answer and it's similar to mine but won't the date groups be sorted in alphabetical order and not chronological order?

Jun
15
1 month ago
Activity icon

Replied to Help Output By Month

You should be able to do a group by on the collection and return the formatted date, something like:

$articles = Article::groupBy(function($article){
  return $article->created_at->firstOfMonth();
})->get();

and in your view, you can format the date to the format you want like:

@foreach($groups as $group)
  <h1>{{ $group->format('M Y') }}</h1>
  <ul>
  @foreach($group->articles as $article)
    <li>{{.$article->title }}</li>
  @endforeach
  </ul>
@endforeach

I am going off of memory on some of this but it should give you an idea as to how to do it. I'm sure there are other ways, too.

Activity icon

Replied to Task And Queues

There are a number of ways to do this and I don't think anything you've mentioned is terrible but I suggest consider subscribing to Shopify webhooks and keep your data synced that way. This could alleviate you having to do this for each shop/customer/product because your app will get notified of the change through the webhook. I've implemented this and it seems to work fine.

https://help.shopify.com/en/manual/orders/notifications/webhooks

Jun
09
1 month ago
Activity icon

Awarded Best Reply on Can't Send Simple E-mail With Laravel

What's the use case to use Vue for mail? If the HTML is in a blade template, you'll need $content - if the HTML is used in javascript within blade template, you'll need @{{ content ...}} to tell blade not to process it.

Jun
08
1 month ago
Activity icon

Replied to Can't Send Simple E-mail With Laravel

What's the use case to use Vue for mail? If the HTML is in a blade template, you'll need $content - if the HTML is used in javascript within blade template, you'll need @{{ content ...}} to tell blade not to process it.

Jun
02
2 months ago
Activity icon

Replied to Access Token In REST API Using Passport

If you are getting the token and only having a problem when the client is refreshed, you could store the token in localStorage but this is now considered a bad practice because other javascript can also access localStorage.

I don't really know so someone else can probably give you better info but as I understand it, storing in a cookie is safer and Sanctum helps with this. I'm sure there are many apps out there saving tokens in localStorage but you need to understand the risks.

Activity icon

Replied to Mail Importance

You can get a reference to the SwiftMessage in the mailable like this:

public function build()
{
  return $this->withSwiftMessage(function ($message) {
    $message->setPriority(\Swift_Message::PRIORITY_HIGH);
  })-> ... do other stuff;
}
Activity icon

Replied to How To Hide Actions In Lenses Laravel-nova

Have you tried using a policy?

Activity icon

Replied to Search In BelongsToMany-relation For Item By Pivot Value

I haven't tested this but you should be able to do something like:

Order::whereDoesntHave('invoices', function ($query) {
  $query->wherePivot('data', '>', Carbon::today()->subMonth());
});

If this doesn't work, it should be some variation of this.

Activity icon

Replied to Cloudinary

Don’t worry about setting a size on upload - you can get the size you need when you request the file: https://cloudinary.com/documentation/image_transformation_reference