trevorpan

at BidBird, LLC

Member Since 2 Years Ago

Experience Points
63,730
Total
Experience

1,270 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
535
Lessons
Completed
Best Reply Awards
2
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 13
63,730 XP
May
05
1 week ago
Activity icon

Replied to $('#flash-overlay-modal').modal Is Not A Function. - JQuery Not Loading On Safari

@frankielee

So, this was a pain.

Thank you so much for the info on slim cdn packages. I didn't think that it would cut out the functionality I needed, but of course - I never looked. Didn't know to.

Appreciate your tip.

So, after investigating the cdn script, I noticed laracasts/flash package uses jquery, but bootstrap 5 does not. Also bootswatch uses jquery, but I could not see an updated version to reflect no jquery.

So I ended up removing bootstrap 5 and downgraded to 4. Also, had to shuffle around the order of the scripts.

<!-- jQuery, Popper.js, and JS  -->
<script   src="https://code.jquery.com/jquery-3.6.0.min.js"   integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4="   crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-Piv4xVNRyMGpqkS2by6br4gNJ7DXjqk09RmUpJ8jgGtD7zP9yug3goQfGII0yAns" crossorigin="anonymous"></script>
<script src="{{ mix('js/manifest.js') }}"></script>
<script src="{{ mix('js/vendor.js') }}"></script>
<script src="{{ mix('js/app.js') }}"></script>
<script>
        $('#flash-overlay-modal').modal();
        $('div.alert').not('.alert-important').delay(4000).fadeOut(750);
</script>

Funny thing is, the vue-instantsearch widget still does not display on this safari on production. But I've got a ticket in with algolia to see if we can address that Invalid character '\ud835' .

Appreciate your help!!!

May
04
2 weeks ago
Activity icon

Replied to $('#flash-overlay-modal').modal Is Not A Function. - JQuery Not Loading On Safari

@frankielee hi there,

gave that a go. Still same error in production. I've even updated vue-instantsearch to the latest version 3.7.0 I put in a request to algolia on that character. Perhaps there's a stray character on their package.

It's just bizarre this is happening.

Have noticed the \ud385 character is not throwing an error locally, and allows the algolia vue-instantsearch widget to function on safari.

The $jquery issue is still occurring locally.

Activity icon

Replied to $('#flash-overlay-modal').modal Is Not A Function. - JQuery Not Loading On Safari

Hi @frankielee ,

Thank you ~

I gave that a go. It does not appear to have done anything. However, my iphone does not throw the error in production.

Could it be the version of safari on an older mac mini?

I do notice a few other errors: Invalid character '\ud835' & jQuery.Deferred exception: $('div.alert'.... And Safari's console is loading the scripts in this order:

app.js
manifest.js
vendor.js
bootstrap.bundle.min.js
jquery-3.5.1.slim.min.js

-almost- in the reverse order that they are in the footer. Is that right? Shouldn't they load in the order on the footerjs?

May
03
2 weeks ago
Activity icon

Started a new Conversation $('#flash-overlay-modal').modal Is Not A Function. - JQuery Not Loading On Safari

This one's got me.

So, when in local development I can view .vue components in safari. This means $('#flash-overlay-modal').modal is not a function. is not being thrown in the console.

Firefox and Chrome do not throw an error either.

However, when the site goes to production safari cannot find $.

Here's what I've done:

  • uninstalled jquery via npm, commented out includes in bootstrap.js - using a cdn
  • remove the cdn and do the reverse from above.
  • add
        .autoload({
            jquery: ['$', 'window.jQuery']
        })

to the webpack.mix.js file.

Here's the current footerjs.blade file

<!-- jQuery, Popper.js, and JS  -->
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-JEW9xMcG8R+pH31jmWH6WWP0WintQrMb4s7ZOdauHnUtxwoG2vI5DkLtS3qm9Ekf" crossorigin="anonymous"></script>

<script src="{{ mix('js/manifest.js') }}"></script>
<script src="{{ mix('js/vendor.js') }}"></script>
<script src="{{ mix('js/app.js') }}"></script>

<script>
    $('#flash-overlay-modal').modal();
    $('div.alert').not('.alert-important').delay(4000).fadeOut(750);
</script>

Any ideas?

Please remember, the console only throws an error in production on Safari Version 13.1.2 (13609.3.5.1.5) - not chrome, or firefox.

Thank you for any insights...

Mar
17
2 months ago
Activity icon

Replied to Help Implementing Old Vuejs Components In A New Laravel 8 App With Jetstream/Inertia

That's just unfortunate!

@tykus thank you for clarifying ~

Mar
16
2 months ago
Activity icon

Replied to Help Implementing Old Vuejs Components In A New Laravel 8 App With Jetstream/Inertia

that's funny, I was watching this (from a post by @jlrdw ): https://laravel-news.com/youtube-jetstream-discussion between 9:28 - +- 10:30

He mentions sprinkling livewire here and there, and inertia as a data hydration.

So, there's no way to use inertia and allow a simple vue component to work?

Activity icon

Replied to Help Implementing Old Vuejs Components In A New Laravel 8 App With Jetstream/Inertia

ahh, I was concerned on that, but wasn't sure how to handle when it's a simple form.

//web.php
Route::resource('/inquiry',  'ProjectInquiriesController');

//controller.php
return view('inquiry.project-inquiry');

The vue component is a TelephoneInput component that format's phone numbers nicely with flags, etc. vue-tel-input so there isn't any data per se.

That's the line where I'm confused on how to sprinkle in just a little vue here and there!

Activity icon

Replied to Help Implementing Old Vuejs Components In A New Laravel 8 App With Jetstream/Inertia

Hi @tykus

Had tried putting that in the resources/js/Pages folder earlier but received

ErrorException
Undefined variable $page

So I've been hunting around on that and went to the https://github.com/inertiajs/pingcrm/blob/master/resources/views/app.blade.php I added the @ directives in the right place. But still get the Undefined variable $page

What you mentioned above, I tried commenting out:

//<div id="app">
@inertia
...
//</div?

in master.blade.php where the@inertia can create the #app element. I bet it's super basic but still missing something.

Activity icon

Started a new Conversation Help Implementing Old Vuejs Components In A New Laravel 8 App With Jetstream/Inertia

Hello there ~

Just started a new app and decided to try out Jetstream with Inertia. It seems like a really nice combo.

I have a template I created before Jetstream was offered and would like to use it: blade and vuejs components.

//app.js

require('./bootstrap');
global.moment = require('moment');

// Import modules...
import { createApp, h } from 'vue';
import
{ App as InertiaApp,
    plugin as InertiaPlugin
} from '@inertiajs/inertia-vue3';
import { InertiaProgress } from '@inertiajs/progress';

const el = document.getElementById('app');

// old way of initializing vue components
// const app = new Vue({
//     el: '#app',
// });

createApp({
    render: () =>
        h(InertiaApp, {
            initialPage: JSON.parse(el.dataset.page),
            resolveComponent: (name) => require(`./Pages/${name}`).default,
        }),
})
    .mixin({ methods: { route } })
    .use(InertiaPlugin)
    .mount(el);

So the old way of hooking into the el: app was pretty straight forward. But I'm finding that @routes and @inertia in the master.blade.php file causes every page to try to find inertia routes. That seems simple enough, just use the calls on the Jetstream portion of the app.

How do you allow old vue components to continue working?

Feb
02
3 months ago
Activity icon

Replied to How To Store/manipulate Hierarchical Data In Mysql And Laravel That's Sent To Algolia For Search?

Gave this a go, where all upstream relationships are included on each record. Some lvl_1 data do not have subsequent lvl's (headings).

INSERT INTO master_formats (lvl_1, lvl_2, lvl_3, lvl_4, lvl_5)
VALUES ('03 Concrete', NULL, NULL, NULL, NULL);
INSERT INTO master_formats (lvl_1, lvl_2, lvl_3, lvl_4, lvl_5)
VALUES ('03 Concrete', 'Sections', NULL, NULL, NULL);
INSERT INTO master_formats (lvl_1, lvl_2, lvl_3, lvl_4, lvl_5)
VALUES ('03 Concrete', 'Sections', '03 01 00 Maintenance of Concrete', NULL, NULL);
INSERT INTO master_formats (lvl_1, lvl_2, lvl_3, lvl_4, lvl_5)
VALUES ('03 Concrete', 'Sections', '03 01 00 Maintenance of Concrete', '03 01 10 Maintenance of Concrete Forming and Accessories', NULL);
INSERT INTO master_formats (lvl_1, lvl_2, lvl_3, lvl_4, lvl_5)
VALUES ('03 Concrete', 'Sections', '03 01 00 Maintenance of Concrete', '03 01 30 Maintenance of Cast-in-Place Concrete', NULL);
INSERT INTO master_formats (lvl_1, lvl_2, lvl_3, lvl_4, lvl_5)
VALUES ('03 Concrete', 'Sections', '03 01 00 Maintenance of Concrete', '03 01 30 Maintenance of Cast-in-Place Concrete', '03 01 30.51 Cleaning of Cast-in-Place Concrete');

This causes an issue where when looping through each record the heading '03 Concrete' shows up for every record. That's what I was trying to prevent from happening with:

        @foreach($masterFormats as $masterFormat)
            @if ($masterFormat->lvl_1 !=  NULL)
                <option value="{{ $masterFormat->lvl_1 }}">{{ $masterFormat->lvl_1 }}</option>
            @continue

            @endif
        @endforeach
Feb
01
3 months ago
Activity icon

Started a new Conversation How To Store/manipulate Hierarchical Data In Mysql And Laravel That's Sent To Algolia For Search?

Good evening ~

I've found a few posts which show how to prepare data that will be used in the Algolia Hierarchical menu and Vue. https://www.algolia.com/doc/api-reference/widgets/hierarchical-menu/js/

Solutions for preparing data via scout: https://discourse.algolia.com/t/laravel-vue-instantsearch-tree-menu/6526 https://discourse.algolia.com/t/how-to-structure-product-data-for-nested-catalogue-facets/1968/5

But I'm running into issues on storing categories in mysql which will be looped through in html selects to display to manufacturers. These manufacturers will select categories that their products belong to.

The challenge is storing the data on laravel/mysql side while making it possible to prepare for sending to Algolia. For example, I've made the columns strings even though 03 is an integer because it doesn't seem obvious on how to concatenate an integer designation and a string such as: 03 . Concrete. To display as 03 Concrete.

Instead, I thought using a string as column type: '03 Concrete' would work as Algolia will match characters in a search.

e.g. here's a sample sql insert into a mysql table that will populate categories in the html selects:

INSERT INTO master_formats (lvl_1, lvl_2, lvl_3, lvl_4, lvl_5)
VALUES ('03 Concrete', NULL, NULL, NULL, NULL);

INSERT INTO master_formats (lvl_1, lvl_2, lvl_3, lvl_4, lvl_5)
VALUES (NULL, 'Sections', NULL, NULL, NULL);

INSERT INTO master_formats (lvl_1, lvl_2, lvl_3, lvl_4, lvl_5)
VALUES (NULL, NULL, '03 01 00 Maintenance of Concrete', NULL, NULL);

INSERT INTO master_formats (lvl_1, lvl_2, lvl_3, lvl_4, lvl_5)
VALUES (NULL, NULL, NULL, '03 01 30 Maintenance of Cast-in-Place Concrete', NULL);

INSERT INTO master_formats (lvl_1, lvl_2, lvl_3, lvl_4, lvl_5)
VALUES (NULL, NULL, NULL, NULL, '03 01 30.51 Cleaning of Cast-in-Place Concrete');

In the last row lvl_5 has all the previous lvl's as NULL.

While we can set hierarchical columns adjacent in algolia populating the forms a user would select from on the app/laravel side is difficult.

For example, I've inserted the above, looped through (5) different selects, but the five different html selects cascade to the right and an issue arises. How does lvl_5 know it belongs to lvl_4 and that to lvl_3?

Questions: 1 - Should each record have all five lvl's filled out? e.g. VALUES ('03 Concrete', 'Sections', '03 01 00 Maintenance of Concrete', '03 01 30 Maintenance of Cast-in-Place Concrete', '03 01 30.51 Cleaning of Cast-in-Place Concrete');

2 - Is storing the levels as strings the best option with regards to sending to algolia?

EDIT: Just gave this a shot:

<div class="form-group">
    <label for="lvl_1">MasterFormat Level 1</label>
        <select class="form-control"
            id="lvl_1"
            value="{{ old('lvl_1') }}"
            name="lvl_1"
        >

        @foreach($masterFormats as $masterFormat)
                @if ($masterFormat->lvl_1 !=  NULL)
                    <option value="{{ $masterFormat->lvl_1 }}">{{ $masterFormat->lvl_1 }}</option>
                @continue

            @endif
        @endforeach

    </select>
</div>

This solves the issue of NULL column values populating the select, but still is this ideal? Should each record contain data at each level?

Jan
28
3 months ago
Activity icon

Replied to Vue+Algolia: Overriding Facet Name In Vue-instantsearch RefinementList

@gamewisp

What is this method? <div :class="bem()"

I have the exact same issue - if you remember can you please reply?

Thank you ~

Jan
23
3 months ago
Activity icon

Replied to Clarification With How To Set Console/kernel.php

@fylzero Had one more thought.

So, for an example, this property declaration protected $commands = [could be used if you have commands in a large app that are stored outside the traditional App\Console directory?

Activity icon

Replied to Clarification With How To Set Console/kernel.php

geez, I knew something was wrong.

I might try to contribute and add a note about this on the docs.

Appreciate your help!

Activity icon

Replied to Clarification With How To Set Console/kernel.php

@fylzero You know what's so strange, is that I just tried commenting out:

 protected $commands = [
 //       Commands\DeadlineHasPassed::class,
 //       Commands\GenerateSitemap::class,
    ];

Ran CI and then the bloody Deadline email sent! Could having the directory in the commands()create a sort of strange loop?

Or... is it that because $this->load(__DIR__.'/Commands'); then creates /Commands/Commands/DeadlineHasPassed::class,? Was that the issue maybe?

Activity icon

Started a new Conversation Clarification With How To Set Console/kernel.php

Hello there ~

https://laravel.com/docs/8.x/scheduling#defining-schedules

On the above link the protected $commands = [.. is empty and so I'm finding it confusing. The protected function commands() method tells this Kernel file where to find custom commands.

Am I declaring it improperly in protected $commands?

class Kernel extends ConsoleKernel
{
    /**
     * The Artisan commands provided by your application.
     *
     * @var array
     */
    protected $commands = [
        Commands\DeadlineHasPassed::class,
        Commands\GenerateSitemap::class,
    ];

.... // $scheduled tasks

/**
     * Register the commands for the application.
     *
     * @return void
     */
    protected function commands()
    {
        $this->load(__DIR__.'/Commands');

        require base_path('routes/console.php');
    }
Jan
18
4 months ago
Activity icon

Replied to Not Yet Created Variables Crash Blade View With Different States

I'll have to play around with that - Thank you for the link though - you've written a great set of docs there!

The link above is a bit different than the blade view issue I ran into. (if I understand right). The situation I have is where one user makes a model, and then other users react to it.

Activity icon

Replied to Not Yet Created Variables Crash Blade View With Different States

@snapey that's really clever and time saving. I can see a ton of places to refactor.

Hypothetical - if a site can have blog posts, and many users making blog posts. How does that work?

e.g. site.test/blogpost/create

If a user creates a post such as site.test/blogpost/{id} if they want to update the post they're not able to got to site.test/blogpost/create again? Can you clarify the routes?

Activity icon

Replied to Not Yet Created Variables Crash Blade View With Different States

Wow @thinkverse that's reason enough to upgrade. Plan to shortly.

I was having trouble with the optional. optional($lowBid) did not prevent the error, just gave this a go: $lowBid = optional($job->bids->firstWhere(min(['bid']))); seems to work!

Thank you for the tips. Trevor

Jan
17
4 months ago
Activity icon

Started a new Conversation Not Yet Created Variables Crash Blade View With Different States

$lowBid = $job->bids->firstWhere(min(['bid']));

ErrorException Trying to get property 'bid' of non-object

So, this blade view has numerous states.

  • When a job is initially posted (bid is not yet created and crashes view)
  • When a bidder places a bid
  • When the deadline ends

Is optional() the way to go? How would you handle this?

Jan
13
4 months ago
Activity icon

Replied to Test Code Or Tested Code Did Not (only) Close Its Own Output Buffers & ActingAs()

@brandonsurowiec oh great. Appreciate you adding some more depth to the post! Thank you ~

Dec
28
4 months ago
Activity icon

Replied to How To Rerun Routes\web.php After Logging In And Before Intended() Kicks In

ahh, is it normal for phpstorm to reject this? if (Auth::check() && Auth::user()->hasVerifiedEmail()) { it says method not found.

Anyhow, just tested locally. Put email_verified_at = NULLtried to access while logged in .... GUEST PAGE!

Then quickly NOW() to re-verify and voila -> auth page!

Thank you so much ` @tray2

Activity icon

Replied to How To Rerun Routes\web.php After Logging In And Before Intended() Kicks In

Hi @tray2

Was looking into this this morning, but when I got to User model I noticed I have this: class User extends Authenticatable implements MustVerifyEmail that should be all we need, right?

Dec
26
4 months ago
Activity icon

Replied to How To Rerun Routes\web.php After Logging In And Before Intended() Kicks In

@tray2

You're a very smart man.

OK (2 tests, 6 assertions)

Ok, how about the 'verified' middleware, that's a good idea, right? I was thinking a person who hasn't verified their account shouldn't be able to take auth actions on the site.

Or would it be better to have verified on login? Maybe that'd be the best place for that.

...

After looking into this I found: Auth::routes(['verify' => true]); accomplishes this. So, really I've never needed verified in the route group.

Also, I understand now, the auth middleware functionality happens when they log in. This was a head shift.

Thank you so much ~

Activity icon

Replied to How To Rerun Routes\web.php After Logging In And Before Intended() Kicks In

Ok, I removed the showGuest route, saved, and then ran php artisan optimize then php artisan config:clear.

When running the test keep getting unauthenticated.

Doesn't the route group of ['auth', 'verified'] override this guest route?

Here's the test:

     /** @test */
    public function a_guest_user_can_view_an_individual_job()
    {
        $this->withoutExceptionHandling();

        $job = (factory(SlugJob::class)->create([
            'slug' => 'foo-title'
        ]));
        
        $response = $this->get('/jobs/foo-title');

        $response->assertStatus(200);
        $response->assertSee($job->jobtitle);
    }
Activity icon

Replied to How To Rerun Routes\web.php After Logging In And Before Intended() Kicks In

Hi @tray2

What a good idea.

Just gave it a shot: Illuminate\Auth\AuthenticationException: Unauthenticated.

So, the view would still need a route defined?

I moved the guest route and action below like this:

//routes\web.php


Route::middleware(['auth', 'verified'])->group(function () {
...
Route::get('/jobs/{job}', '[email protected]');
...
});



Route::get('/jobs/{job}/guest', '[email protected]')->middleware(['web', 'guest']);

not sure if we need to add /guest but I've been going back and forth with this concept for a while - just don't have it quite right...

Should the guest method concatenate/jobs/{job}' . '/guest'? Or something like that?

Activity icon

Started a new Conversation How To Rerun Routes\web.php After Logging In And Before Intended() Kicks In

Goal is to have two views; one for auth and one for guest.

Have found quite a few posts on laracasts.com that got me here.

//routes\web.php

if(Auth::check()) {
        Route::get('/jobs/{job}', '[email protected]')->middleware(['auth', 'verified']);
} else {
        Route::get('/jobs/{job}', '[email protected]')->middleware(['web', 'guest']);
    });
}

What I'm finding is if an email gives a link to say site.test/jobs/{job} the guest view will display. Good. However, when you login from the call to action button intended() routes the guest route.

I'm pretty sure this is because the intitial check in web.php returned the guest route.

Am I right? Do you know how to solve this?

Thank you ~

Dec
22
4 months ago
Activity icon

Replied to Spatie Media-Library Pro Error With Blade Component & Livewire

has anyone run into this?

I'm unable to get the Dropzone file uploader to pop up or work. On inspect I can see: Livewire Scripts & https://cdn.jsdelivr.net/gh/alpinejs/[email protected]/dist/alpine.min.js so I'm pretty sure they're there.

this is how it's called in blade:

<x-media-library-attachment
    multiple
    name="media"
    max-items="10"
    rules="mimes:png,jpg,jpeg,pdf|max:15360"
    required
>
</x-media-library-attachment>

Can't think of a reason why the js would not work...

Any ideas?

Dec
19
4 months ago
Activity icon

Replied to Access Model From MessageSent $event

haha.

Basically sending an email, then in a webhooks table save the event that occured, such as unsubscribed. Then I can have a job that soft_deletes the email sent.

To compare events to the source email..

Your solution on the trim was great. Using $this worked too and got rid of that use statement. I thought perhaps I was trying to access it incorrectly..

Thank you! @michaloravec

Activity icon

Replied to Access Model From MessageSent $event

Hi @michaloravec would you trim them?

I read the email provider does that for the header, but not sure if storing the characters is wise.

Activity icon

Replied to Access Model From MessageSent $event

gah, after writing this post I thought of a new way to query the web. Have a solution:

//in the mail build()
    public function build()
    {

        $invitation = $this->invitation;
        $this->withSwiftMessage(function ($message) use($invitation) {
            $message->invitation = $invitation;
        });
...  
//mail stuff
//listener to MessageSent $event (event is registered in event service provider)
        $id = $event->message->getHeaders()->get('Message-ID')->getFieldBody();


        $event->message->invitation->update([
            'message_id' => $id
        ]);

the last issue I've got is the message_id comes in as <aad3521e3ff9e9bbae15596c89468241@swift.generated>

How do we strip the < and > or are they ok to store? I want to store the id so I can compare emails sent to the events that happen to them.

Activity icon

Started a new Conversation Access Model From MessageSent $event

I'd like to access $invitationso I can update the message_id column.

use Illuminate\Mail\Events\MessageSent;
....

/**
     * Handle the event.
     *
     * @param MessageSent $event
     * @return void
     */
    public function handle(MessageSent $event)
    {

        $id = $event->message->getHeaders()->get('Message-ID')->getFieldBody();

        // dd($id); 

        $this->event->invitation->update([
            'message_id' => $id
        ]);

So, $id returns an id with header symbols: <> not sure if those should be saved to compare for future use?

PHPUnit 9.5.0 by Sebastian Bergmann and contributors.

.."<[email protected]>"

At any rate I can see the invitation in the $event response, but it's not accessible via eloquent.

e.g. $event->invitation

Thank you

Dec
10
5 months ago
Activity icon

Replied to Error: Call To A Member Function Update() On Int

Time: 00:00.916, Memory: 36.50 MB

OK (1 test, 4 assertions)
(base) Trevors-Mac-mini:bidbird trevorpan$ 

You have no idea, I"ve been banging my head on this all morning and afternoon!!!

I had tried $invitation->update() but can't remember why I was unable to get that to work.

Thank you so much @michaloravec ~ Trevor

Activity icon

Started a new Conversation Error: Call To A Member Function Update() On Int

                    DB::transaction(function () use ($invitation) {
                        DB::table('invitations')
                            ->where('id', $invitation->id)
                            ->update(['updated_at' => Carbon::now()->toDateTimeString()])
                            ->increment('times_sent'); // gives error
                    });

Keep getting this error: Call to a member function update() on int. I feel like this may be because the DB pulls a stdClass not an eloquent model.

Tried using:

                            $invite = Invitation::where('id', $invitation->id) // also tried just $invitation
                            ->increment('times_sent', 1);
                            ->update(['updated_at' => (Carbon::now('America/Los_Angeles')->toDateTimeString())]);

Still gives an error Error: Call to a member function update() on int

Anyone have any ideas?

Dec
03
5 months ago
Activity icon

Started a new Conversation Spatie Media-Library Pro Error With Blade Component & Livewire

Was wondering if anyone has implemented the components, they display properly, but the js does not pop up a file modal. Dragging a file to the form is rejected.

Have livewire installed @includes in head and footer, added to webpack.mix.js

mix.js('resources/js/app.js', 'public/js')
        .sass('resources/sass/app.scss', 'public/css')
        .version()
        .options({
            processCssUrls: false
        })
    .webpackConfig({
        resolve: {
            modules: [
                "node_modules",
                __dirname + "/vendor/spatie/laravel-medialibrary-pro/resources/js",
            ],
        },
    });

"laravel-mix": "^4.0.15",

https://spatie.be/docs/laravel-medialibrary/v9/handling-uploads-with-media-library-pro/handling-uploads-with-blade#handling-multiple-uploads

Nov
20
5 months ago
Activity icon

Awarded Best Reply on Queue Jobs Only Process On "sync" Connection Not "redis" In Local Dev

@rodrigo.pedra !!!

Man, this was really a nightmare. I recently picked up Laravel Queues in Action pdf and did not observe the book speaks about jobs as in the php artisan created jobs class. So I added these traits: use SerializesModels, InteractsWithQueue, Queueable; to the listener and tried to use public properties.

which caused this beast: Symfony\Component\ErrorHandler\Error\FatalError App\Listeners\SendMessageNotification and Illuminate\Bus\Queueable define the same property ($queue) in the composition of App\Listeners\SendMessageNotification. However, the definition differs and is considered incompatible. Class was composed

I had to go back and really read each and every section on queued mailables and listeners and properly declare the properties and removed the traits.

Anyhow, thank you for pointing me in the right direction!

class SendMessageNotification implements ShouldQueue
{
// removed these traits!
//    use  SerializesModels, InteractsWithQueue, Queueable;



    /**
     * The name of the queue the job should be sent to.
     *
     * @var string|null
     */
    public $queue = 'listeners';



    /**
     * Set the event listener queue configuration
     *
     * @return void
     */
    public function __construct()
    {

    }

    /**
     * Handle the event.
     *
     * @param MessageSent $event
     * @return void
     */
    public function handle(MessageSent $event)
    {
        Mail::to($event->Message->email)->send(
            new MessageSentMail($event->Message)
        );
    }
Activity icon

Replied to Queue Jobs Only Process On "sync" Connection Not "redis" In Local Dev

@rodrigo.pedra !!!

Man, this was really a nightmare. I recently picked up Laravel Queues in Action pdf and did not observe the book speaks about jobs as in the php artisan created jobs class. So I added these traits: use SerializesModels, InteractsWithQueue, Queueable; to the listener and tried to use public properties.

which caused this beast: Symfony\Component\ErrorHandler\Error\FatalError App\Listeners\SendMessageNotification and Illuminate\Bus\Queueable define the same property ($queue) in the composition of App\Listeners\SendMessageNotification. However, the definition differs and is considered incompatible. Class was composed

I had to go back and really read each and every section on queued mailables and listeners and properly declare the properties and removed the traits.

Anyhow, thank you for pointing me in the right direction!

class SendMessageNotification implements ShouldQueue
{
// removed these traits!
//    use  SerializesModels, InteractsWithQueue, Queueable;



    /**
     * The name of the queue the job should be sent to.
     *
     * @var string|null
     */
    public $queue = 'listeners';



    /**
     * Set the event listener queue configuration
     *
     * @return void
     */
    public function __construct()
    {

    }

    /**
     * Handle the event.
     *
     * @param MessageSent $event
     * @return void
     */
    public function handle(MessageSent $event)
    {
        Mail::to($event->Message->email)->send(
            new MessageSentMail($event->Message)
        );
    }
Nov
17
6 months ago
Activity icon

Replied to Queue Jobs Only Process On "sync" Connection Not "redis" In Local Dev

Hi @rodrigo.pedra

Yes, I certainly have that going and run terminate off there’s any code changes.

Can you imagine why they wouldn’t process? Have gone over it so many times I think I’m missing something very basic.

Thank you!

Activity icon

Started a new Conversation Queue Jobs Only Process On "sync" Connection Not "redis" In Local Dev

Hi there.

Having quite a time with queues.

In the laracasts notification videos we can create an event and set multiple listeners to send mail notifications, etc. I had this working for months.

After installing horizon, though, I found messages failed to send on production.

So, I've been trying to figure out what's happening. When I test, locally, the $connection = 'redis'; a listener will pop up on the horizon/pending jobs tab. But the mail will not process.

When I test, locally, the $connection = 'sync'; a listener will pop up on the horizon/pending jobs tab. But the mail will process and is sent to mailtrap.

So, if we use horizon do we need to create a app\jobs\class to process the queue?

Thank you ~