packy

packy

Member Since 4 Years Ago

Coeur d’ Alene

Experience Points
29,330
Total
Experience

670 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
232
Lessons
Completed
Best Reply Awards
1
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 6
29,330 XP
Jun
23
1 month ago
Activity icon

Replied to Issue With Encryption Decryption In Laravel Query Builder

How did you end up doing this? I am trying to search encrypted data with Laravel Nova

Activity icon

Replied to Change How Resousrce And Global Search Work

Okay, so if I do this:

public static function indexQuery(NovaRequest $request, $query)
    {
        if (request()->filled('search')) {
            $term = $request->search;

            $matches = AppConsumer::all()->filter(function ($record) use ($term) {
                if ($record->email == $term) {
                    return $record;
                }
            });

            return $matches;
        }

        return $query;
    }

it returns noting. But if I dd($matches); before the return it shows what I need. What am I missing?

Activity icon

Replied to Change How Resousrce And Global Search Work

Is there any docs on this? I guess I dont understand what ->filled('filters') is and $query->whereNull('downloaded_at'); or is that just and example?

Activity icon

Started a new Conversation Change How Resousrce And Global Search Work

Right now my app only has 2 resources I want searched. Both resources will need to search an email column that is encrypted. I currently use something like this to find the records since they are encrypted:

Consumer::all()->filter(function ($record) use ($email) {
            if ($record->email == $email) {
                return $record;
            }
        });

How can I adjust the how "search" is done? Its a must for the app per the client, but so is encrypting PII. I should be able to use that same chunk of code if I knew where to overwrite how to search

Jun
19
1 month ago
Activity icon

Started a new Conversation Ignore Error From Mail Method

Is there a way to ignore any errors from a Mail method? Here is the scenario, I have an online ordering system that doesn't require you to be a user. When someone places and order, the controller stores the order in the DB and then sends an email to the customer "hey we got your order, here is the receipt". This works great until a user misspells his email. So 1 out of every 1000 orders someone will accidentally use something like "@gmail.con" instead of "@gmail.com". When Mailgun goes send it the systems throws a 500 error because its not a real email. This then pops up on the users screen so they think the order wasn't placed even though it was. How to you handle this? Can you ignore an error from Mail::to($this->email)->send(new NewOrderCustomer($order, $location)); so if they use a wrong email its just on them? We just dont want users to place 10 orders because they think its an order error. Or how can you verify its a real email?

Jun
17
1 month ago
Activity icon

Started a new Conversation Storage PutFile 504 Error

I am uploading a large file to S3 and getting a 504 Gateway Timeout error returned to me. That confusing part is the file does indeed still upload, but on the frontend after a bit I get the 504 error? I am streaming the file so I thought this would prevent burning resources?

Here is the full code:

 public function store(Request $request)
    {

        $request->validate([
            'email' => 'required|email',
            'video' => 'required',
        ]);


        if ($request->hasFile('video')) {

            //Upload original file
            $original_key = Storage::putFile(
                'originals',
                new File($request->file('video')),
                ['Content-Disposition' => 'attachment']
            );

            //Convert file for preview
            $config = [
                'PresetId' => '1351620000001-100070',
                'width'  => 1920,
                'height' => 1080,
                'aspect' => '16:9',
                'ext'     => 'mp4',
                'PipelineId' => env('PIPELINE_ID'),
            ];

            $elastcoder = new ElastcoderAWS();

            $original_array = explode('/', $original_key);
            $preview_key = end($original_array);

            $thumbPattern = "thumbnails/{$preview_key}-{count}";

            $job = $elastcoder->transcodeVideo($original_key, $preview_key, $config,  $thumbPattern);


            $submission = new Submission();

            $submission->email = $request->input('email');
            $submission->original = config('filesystems.disks.s3.url') . $original_key;
            $submission->preview = config('filesystems.disks.s3.url') . $preview_key;
            $submission->thumbnail = config('filesystems.disks.s3.url') . "thumbnails/{$preview_key}-00001.png";
            $submission->transcoding_id = $job["Id"];


            $submission->save();

            return response()->json([
                'submission' => $submission,
                'message' => 'Video Upload. Good Luck!!!'
            ]);
        } else {

            return response()->json([
                'submission' => false,
                'message' => 'Upload Error. Please try again later.'
            ]);
        }
    }
Jun
16
1 month ago
Activity icon

Replied to Re Check If Statment

After some research the best way would probably be a command with a cron job.

Activity icon

Started a new Conversation Update Resource From Index

Is there a way to update a resource record from the index view? I would imagine I could create a custom field to do this but have not seen much information. All I found in the FormField.vue file of a custom field is methods on how to populate the value and pass the value to the formdata in the edit view.

Here is the use case: many time when I have an backend that handles things like orders, it seems like a good UX would be to update an orders status from the index view, not click to edit, click select a new status, click save. From index view you could have a select field that would save the new status value when its changed. Much faster for something simple like that.

Anyone had experience with this?

Activity icon

Started a new Conversation Re Check If Statment

What is the best way to keep checking a condition until it is true? I know there is a while statement in PHP but was not sure if there is a better packaged way in Laravel.

Basically I am transcoding a video through AWS. I want the frontend to keep saying "Uploading" until I know the video is transcoded and saved in AWS and all info is in the database. The videos will be short, but still transcoding is not instant so if I do:

if ($job['Status'] == 'complete') {

                    $submission = new Submission();

                    $submission->email = $request->input('email');
                    $submission->original = config('filesystems.disks.s3.url') . $original_key;

                    $submission->save();

                    return response()->json([
                        'submission' => $submission,
                        'message' => 'Upload Successful. Good luck!!!!',
                        'job' => $job
                    ]);
}

This if statement will be false right away. But if I checked again every few seconds it will pass after a little bit. Is there a pulse type function to continue to run that if statement every X amount of time until it passes? Using a while seems to be hitting max_execution_time the limit.

Jun
15
1 month ago
Activity icon

Replied to Video Field

@m7vm7v thanks. I looked at the Nova Packages website already (usually my first stop). I will just move on to making a custom field I guess, just didnt want to reinvent the wheel if there was something. I forgot Laracasts has a whole video on this as well.

Activity icon

Started a new Conversation Video Field

Is there any way to preview a video file in Nova? Basically people submit videos from the frontend and we want to preview the video we uploaded to our S3 through Nova. I figured there would be a video field but I cant seem to find one.

Apr
02
4 months ago
Activity icon

Replied to Forge Redirct Rules Cause "Too Many Redirect"

@bugsysha funny, I did that after all the redirect errors so that works. I still would like to figure out though why that happens with Forge. I imagine setting those redirects is probably a bit more "standard practice"

Activity icon

Started a new Conversation Forge Redirct Rules Cause "Too Many Redirect"

This is confusing me, I am doing a simple permanent redirect from one page to another but it causes and endless loop even though the address are different?

  • From: /cda
  • To: /locations/cda
  • Type: permanent
Mar
31
4 months ago
Activity icon

Replied to Relationship GroupBy In Initial Query

@snapey Yes that was my initial thought but a course has a few things common to all entrees under it like "description" and "sides". But I might re tool it to make it work better

Activity icon

Replied to Relationship GroupBy In Initial Query

@snapey that seems to work as well. Is either option better performance wise I wonder? I am getting Allowed memory size of 134217728 bytes exhausted sometimes on load. Or maybe cache the results since items are rarely added or changed?

Activity icon

Replied to Relationship GroupBy In Initial Query

@snapey yes, like you would see in a regular menu entrees grouped by a course like "appetizers". And a course really shouldn't belong to a location since really each location has all the same courses but not the same entrees under a course. I will give your solution a whirl

Activity icon

Replied to Relationship GroupBy In Initial Query

@snapey the end result is I can loop through the "Groups" to show the course->name and then loop through the entrees that belong to that group AND that location like so (which works with my little hack):

@foreach ($location->entrees as $course => $entrees)

   <h2>{{$course}}</h2>

   <ul>
   @foreach ($entrees as $entree)

      <li>
         <p>{{ $entree->name }}</p>
         <p>{{ $entree->description }}</p>

      </li>

   @endforeach
   </ul>

@endforeach
Activity icon

Replied to Relationship GroupBy In Initial Query

They are as follows:

  • Locations belongsToMany Entrees
  • Entrees belongsToMany Locations
  • Entrees belongsTo Course
  • Course hasMany Entrees
Activity icon

Replied to Relationship GroupBy In Initial Query

@snapey Whoops, fixed that mishap, groupBy is what I am looking for

Activity icon

Started a new Conversation Relationship GroupBy In Initial Query

I am trying to groupBy a relationship in the initial query from my controller but not having such luck. For now I have a workout, but seems clunky:

public function menu(Location $location)
    {
        $location->entrees = $location->entrees->groupBy(function ($entree) {
            return $entree->course->name;
        });

        return view('food-order.menu', compact('location'));
    }

I thought it would look something like this

public function menu(Location $location)
    {
       $location->load(['entrees' => function ($q) {
            $q->groupBy(function ($entree) {
                return $entree->course->name;
            });
        }]);

        return view('food-order.menu', compact('location'));
    }

but get the error: stripos() expects parameter 1 to be string, object given. Is this way off target of how I should do this???

Mar
24
4 months ago
Activity icon

Replied to Nova Resource From API Data

@simber @zhxscript Was there any examples anyone can post? I was thinking of adding a "Products" resource that connected to a Shopify account.

Mar
18
4 months ago
Activity icon

Commented on The New HTTP Client

Just reached for this today and made it so much easier/clear to get data from a third party API

Mar
14
4 months ago
Activity icon

Started a new Conversation Checkout/Cart In Modals Or Pages

I am building an ordering system for a client and have been reviewing checkout flows. While I like the look of slide out cart modals and a checkout modal (similar to Bolt and ones you see on Shopify) I cant help but think that if I should follow anyone's example, it should be Amazon. Since they are the biggest e-commerce store I would assume they invested a lot of money into the best way to get conversions. Pages also seem better for mobile possibly over modals.

No real technical question here, just thought it would be interesting to hear peoples thoughts.

Mar
06
5 months ago
Activity icon

Replied to Add Style Tag To Laravel 7 Component With @section

@snapey @stack seems to work in the component where @section does not. Not sure why but I will read more about stacking

Activity icon

Replied to Add Style Tag To Laravel 7 Component With @section

Correct, I Dont have to but adding them to the body (within the main #app div) will always throw a Vue error complaining:

”Templates should only be responsible for mapping the state to the UI. Avoid placing tags with side-effects in your templates, such as , as they will not be parsed.”

Activity icon

Started a new Conversation Add Style Tag To Laravel 7 Component With @section

I love how Vue files have the ability to add style right in the file, keep things tidy and reusable if I want to copy to another project. Laravel 7 components have some great use cases but is there a way to add style to the component besides just inline? I can get away with Tailwind classes most the time, but sometimes I need some extra. I would love doing this in a component:

<div
    class="banner relative  bg-carbon-900 py-4 text-white font-heading tracking-wider text-center text-3xl uppercase border-green md:text-5xl">

    <p>{{ $text }}</p>

</div>

@section('head')
<style>
    .banner {
        transform: skewY(-5.6deg);
        margin-top: -89px;
        overflow: hidden;
        border-top-width: 20px;
        border-bottom-width: 20px;
    }


    .banner p:before,
    .banner p:after {
        border-top: 4px dotted white;
        content: '';
        display: table-cell;
        position: relative;
        top: 1.3rem;
        width: 45%;
    }
</style>
@endsection

This way it would add the style to the head of my site layout where the component is used. Yet, it doesnt, I imagine because it just renders the view? Maybe this could be added to Laravel 7??

Mar
01
5 months ago
Activity icon

Replied to Search Relationship With "like"

@snapey that returns an error Too few arguments to function Illuminate\Support\Collection::get(), 0 passed

Activity icon

Replied to Search Relationship With "like"

@sinnbeck wouldnt that return a "Conference" that has an "Attendee" based on the search and not a collection of the "Attendees" that belong to that "Conference" matching the search?

@snapey The Attendees relationship belongs to the User model. That model has a conference relationship that looks like:

 public function conferences()
    {
        return $this->belongsToMany(Conference::class);
    }

So would it be:

`User::whereHas('conferences', function ($query) use ($conferenceId) {
    $query->where('id', $conferenceId);
})->where('name', 'like', '%' . $query . '%')->get();
Activity icon

Started a new Conversation Search Relationship With "like"

I am trying to search a relatiship and return a collection of that relationship by using like but not having any luck. Basically I am using Livewire for a list with a search. Once you are typing it will update the list with results based upon your search thus far. I have done this a lot when searching a model but with a relationship I am getting no results.

Example

If I do a where search with a full search parameter I know exists, it works:

public static function searchAttendees($conferenceId, $query)
    {

        $conference = static::where('id', $conferenceId)->with('attendees.socials')->first();

        return $conference->attendees->where('name', $query );

    }

but this would require a correct full $query like "John Smith", not a live search where results populate while typing. What I usually do is use like when searching but that doest seem to work with a relationship

 public static function searchAttendees($conferenceId, $query)
    {

        $conference = static::where('id', $conferenceId)->with('attendees.socials')->first();

        return $attendees = $conference->attendees->where('name', 'like', '%' . $query . '%');

    }

but this doesnt return any results when I start typing "John Smith" even though I know that record would exists on as an Attendee at that Conference

Feb
18
5 months ago
Activity icon

Replied to Get "Grandparent" Relationship From Child

Never mind. I just ended-up walking up the chain. Not sure why I didnt do that in the first place?????

so to get the slug I just needed:

$this->productType->shopCategory->slug

Activity icon

Started a new Conversation Get "Grandparent" Relationship From Child

So I have been trying to figure this out for a while and I just kind find the right relationship, or am using it wrong. Basically I am trying to get the "Grandparent" relationship from the child. Right now I have 3 tables:

merchandises
-id
-product_type_id;
-name;
-description;
-slug;

product_types
-id
-shop_category_id;
-name;
-slug;

shop_categories
-id
-name;
-slug;

So on the Merchidese model I want to be able to get the shop_category slug. I thought the relationship would be

public function shopCategory()
    {
        return $this->hasOneThrough(ShopCategory::class, ProductType::class);
    }

but that assumes product_types has a merchandise_id which it doesnt.

Merchandise HasOne ProuductType that HasOne ShopCategory. So how do I get the ShopCategory from the Merchandise??

Feb
11
5 months ago
Activity icon

Replied to Getting E-Commerce Parcel Size

Thats @sti3bas . I will check that out

Activity icon

Started a new Conversation Getting E-Commerce Parcel Size

I am currently building an e-commerce solution for a company and having trouble wrapping my head around shipping costs. I am using Shippo and I can easily get rates, labels and really everything I need, the issue is not a technical one with their API. I am just curious how you find the Parcel size to get rates before we package it. Right now the systems works like any other: you click to checkout, we know whats in your cart, you fill out shipping destination and the API returns rates. To get the rates I need to provide the parcel weight and size. I can add all the weights of items but how do you figure a box size? If the item is 4X1X1 that is not the actual box size, just the item size. If we have multiple items how can a pick a box size? I assume most people just use the same box size for 1 item as the do 5 items.

Here is the Shippo tutorial I used:

https://m.dotdev.co/easily-handle-shipping-in-laravel-with-shippo-12055c903704

Here is what I need to pass Shippo to get rates for the user to select (Parcel is the final package to send):

$parcel = array(
    'length'=> '5',
    'width'=> '5',
    'height'=> '5',
    'distance_unit'=> 'in',
    'weight'=> '2',
    'mass_unit'=> 'lb',
);

$shipment = Shippo_Shipment::create( array(
    'address_from'=> $fromAddress,
    'address_to'=> $toAddress,
    'parcels'=> array($parcel),
    'async'=> false
    )
);