chrisgrim

chrisgrim

at Self Employed

Member Since 1 Year Ago

Petaluma

Experience Points
27,190
Total
Experience

2,810 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed
136
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start-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-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-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist 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
27,190 XP
Jan
24
2 days ago
Activity icon

Replied to Need Help Setting Up Messaging Database Correctly

@pom I believe this gets me all the messages that I have sent and received. How do I group it into groups like these are all the messages that user with an id of 4 and me have sent and received?

Activity icon

Started a new Conversation Need Help Setting Up Messaging Database Correctly

Hi, I am struggling to setup my messaging database. I want users to be able to message each other and then see those conversations. I originally setup my database like

$table->bigIncrements('id');
            $table->unsignedBigInteger('sender_id');
            $table->unsignedBigInteger('sent_to_id');
            $table->text('body');
            $table->timestamps(); 
            $table->foreign('sender_id')
                    ->references('id')->on('users')
                    ->onDelete('cascade');
            $table->foreign('sent_to_id')
                    ->references('id')->on('users')
                    ->onDelete('cascade');

In my user model I have

public function received()
    {
        return $this->hasMany(Message::class, 'sent_to_id');
    }
 public function sent()
    {
        return $this->hasMany(Message::class, 'sender_id');
    }

Which works, but now I am struggling to correctly display those messages. I can easily get all the sent messages and received messages for a user but when I try to create a method to group them into only the messages between two users it is getting more complicated. Id like to return a collection from laravel that has

1[
Message with sender_id = 1 and sent_to_id = 2 body = text here
Message with sender_id = 2 and sent_to_id = 1 body = text here
Message with sender_id = 1 and sent_to_id = 2 body = text here
]
2[
Message with sender_id = 1 and sent_to_id = 4 body = text here
Message with sender_id = 4 and sent_to_id = 1 body = text here
]
3[
Message with sender_id = 16 and sent_to_id = 1 body = text here
Message with sender_id = 1 and sent_to_id = 16 body = text here
]

Am I going about this the correct way or should I be looking at pivot tables?

Jan
23
3 days ago
Activity icon

Replied to Laravel Allowing Me To Login Through Axios Without Csrf

I have that file, but it isn't called anywhere.

Activity icon

Replied to Laravel Allowing Me To Login Through Axios Without Csrf

I have it deactived

// require('./bootstrap');

in my app.js file

Activity icon

Replied to Laravel Allowing Me To Login Through Axios Without Csrf

Hi @armancodes I had it deactivated in my app.js file however when I reactivate it I still have no trouble logging in. Does that mean it is working?

Activity icon

Started a new Conversation Laravel Allowing Me To Login Through Axios Without Csrf

Hi, I am setting up a Vue / Laravel project and recently discovered something a bit scary. I have the vue Method

login() {
                let data = {
                    email: this.email,
                    password: this.password
                }
                axios.post('/login', data)
                .then(response => {
                    console.log(response.data);
                })
                .catch(errorResponse => { 
                    this.validationErrors = errorResponse.response.data.errors 
                });
            },

and this works. Shouldn't there be a csrf protection? Does this mean with all of my axios posts there is no Cross-site protection?

Activity icon

Replied to Getting A List Of Items From Eloquent

Ahh I see. That makes sense. Thank you so much @kevinbui

Activity icon

Replied to Getting A List Of Items From Eloquent

Hi @ved21212 and @kevinbui

I couldn't really wrap my head around Ved21212's answer. What is it returning?

@kevinbui I think this is close to what I am looking for but I am getting this error.

Column not found: 1054 Unknown column 'favorites.favorite_id' in 'field list' (SQL: select `events`.*, `favorites`.`user_id` as `pivot_user_id`, `favorites`.`favorite_id` as `pivot_favorite_id`, `favorites`.`favorite_type` as `pivot_favorite_type` from `events` inner join `favorites` on `events`.`id` = `favorites`.`favorite_id` where `favorites`.`user_id` = 1 and `favorites`.`favorite_type` = App\Event)

If I look in my database I can see that its favorites.favorited_id and favorited_type. Is this an issue with how I named my database?

Jan
22
4 days ago
Activity icon

Started a new Conversation Getting A List Of Items From Eloquent

Hi, I have setup a hasMany relationship In my user.php using a Polymorphic relationship

    public function favorites() 
    {
        return $this->hasMany(Favorite::class);
    }

my database has

$table->bigIncrements('id');
            $table->unsignedBigInteger('user_id');
            $table->unsignedBigInteger('favorited_id');
            $table->string('favorited_type', 50);
            $table->timestamps();
            $table->unique(['user_id', 'favorited_id', 'favorited_type']);

And in my controller I have

$fav = $user->favorites()->get();

however this just returns my pivot table objects, not the actual events that have been favorited. I know I could do a search using Event::where() but I was wondering if there was a cleaner way to do it like

$fav = $user->favorites()->events->get();

Sorry if this is a silly question

Jan
19
1 week ago
Activity icon

Replied to Having Trouble Setting Up A Regex For Checking Url

@tray2 That worked!! Thanks so much!

Activity icon

Awarded Best Reply on Need Help Understanding Laravel Mix Setup For Vue Async Components

Ok I discovered its because .extract() doesn't work with laravel mix vue async. However, now I am having an issue that even if I have removed the .extract() All of my css files are empty.

Activity icon

Replied to Need Help Understanding Laravel Mix Setup For Vue Async Components

It was because I was trying to do two js files with some of the same files.

Activity icon

Replied to Need Help Understanding Laravel Mix Setup For Vue Async Components

Ok I discovered its because .extract() doesn't work with laravel mix vue async. However, now I am having an issue that even if I have removed the .extract() All of my css files are empty.

Activity icon

Started a new Conversation Need Help Understanding Laravel Mix Setup For Vue Async Components

Hi, My vue app.js is getting rather large so I was going to try use laravel mix async components. I have the latest version of laravel mix and I created the .bablerc file with

{
    "plugins": ["syntax-dynamic-import"]
}

Then inside my applite.js file I changed

Vue.component('event-show', require('./components/events/event-show.vue').default);

to

Vue.component('event-show', () => import('./components/events/event-show.vue'));

in my webpack.mix file I have

const mix = require('laravel-mix');

/*
 |--------------------------------------------------------------------------
 | Mix Asset Management
 |--------------------------------------------------------------------------
 |
 | Mix provides a clean, fluent API for defining some Webpack build steps
 | for your Laravel application. By default, we are compiling the Sass
 | file for the application as well as bundling up all the JS files.
 |
 */

mix.js('resources/js/app.js', 'public/js')
    .js('resources/js/applite.js', 'public/js')
    .extract(['vue','vuelidate','leaflet','vue-router','vuelidate-error-extractor'])
    .sass('resources/sass/app-create.scss', 'public/css')
    .sass('resources/sass/app-admin.scss', 'public/css')
    .sass('resources/sass/app-lite.scss', 'public/css')
    .sass('resources/sass/app.scss', 'public/css');

However when I try to load the page I am now getting the error

manifest.js:85 Uncaught TypeError: Cannot read property 'call' of undefined
    at __webpack_require__ (manifest.js:85)
    at Object../node_modules/css-loader/index.js?!./node_modules/postcss-loader/src/index.js?!./node_modules/leaflet/dist/leaflet.css (vendor.js:145)
    at __webpack_require__ (manifest.js:85)
    at Object../node_modules/leaflet/dist/leaflet.css (vendor.js:14334)
    at __webpack_require__ (manifest.js:85)
    at Module../resources/js/applite.js (applite.js:23295)
    at __webpack_require__ (manifest.js:85)
    at Object.1 (applite.js:24086)
    at __webpack_require__ (manifest.js:85)
    at checkDeferredModules (manifest.js:46)

Do I need to do something else to get it working?

Activity icon

Replied to Having Trouble Setting Up A Regex For Checking Url

Hi @tray2 If I console.log(this.$router.currentRoute.path); I get

/events/test1

However if I do

this.$router.currentRoute.path == `/events/.*` ? console.log('true') : console.log('false');

it returns false. Am I missing something here?

Activity icon

Started a new Conversation Having Trouble Setting Up A Regex For Checking Url

Hi, I am trying to setup a check for a url with a wildcard in Vue/JS. If the url is /events/anythinghere/ then I want it to return true. I have tried

this.$router.currentRoute.path == `/events/*/` ? console.log('true') : console.log('false');

but that isn't working. I am sure I have some syntax wrong and I was hoping someone could set me straight.

Jan
13
1 week ago
Activity icon

Replied to Does It Bother Anyone That Binding Data With Vue Shows It In Source?

@tykus I guess that is a good point! @sti3bas Thanks for this, I will look into it deeper!

Activity icon

Started a new Conversation Does It Bother Anyone That Binding Data With Vue Shows It In Source?

I had setup my site to pass data from laravel blade file to vue using data binding

<event-show :loadevent="{{$event}}">

However I have discovered that it shows every single part of the model in the source if I do this.

<event-show :loadevent="{&quot;id&quot;:1,&quot;user_id&quot;:1,&quot;category_id&quot;:1,&quot;advisories_id&quot;:1,&quot;organizer_id&quot;:1,&quot;slug&quot;:&quot;test1&quot;,&quot;name&quot;:&quot;Test1&quot;,&quot;description&quot;:&quot;Such dun&quot;,&quot;tag_line&quot;:&quot;xzxs&quot;,&quot;websiteUrl&quot;:&quot;http:\/\/www.nolan.com\/ipsam-eius-et-ex-voluptas-sequi-eveniet-nesciunt.html&quot;,&quot;show_times&quot;:&quot;Adawdawd&quot;,&quot;ticketUrl&quot;:&quot;http:\/\/www.nolan.com\/ipsam-eius-et-ex-voluptas-sequi-eveniet-nesciunt.html&quot;,&quot;largeImagePath&quot;:&quot;event-large-images\/test1-3795.jpeg&quot;,&quot;thumbImagePath&quot;:&quot;event-thumb-images\/thumb-test1-3795.jpeg&quot;,&quot;overallRating&quot;:&quot;0&quot;,&quot;location_latlon&quot;:{&quot;lat&quot;:37.7929158,&quot;lon&quot;:-122.40469050000002},&quot;closingDate&quot;:&quot;2020-02-03 00:00:00&quot;,&quot;price_range&quot;:&quot; - 0&quot;,&quot;approval_process&quot;:&quot;approved&quot;,&quot;approved&quot;:1,&quot;created_at&quot;:&quot;2020-01-06 19:59:00&quot;,&quot;updated_at&quot;:&quot;2020-01-07 23:25:17&quot;,&quot;isFavorited&quot;:false,&quot;shows&quot;:[{&quot;id&quot;:1,&quot;event_id&quot;:1,&quot;date&quot;:&quot;2020-01-07 00:00:00&quot;,&quot;created_at&quot;:&quot;2020-01-06 19:59:53&quot;,&quot;updated_at&quot;:&quot;2020-01-06 19:59:53&quot;},{&quot;id&quot;:2,&quot;event_id&quot;:1,&quot;date&quot;:&quot;2020-01-08 00:00:00&quot;,&quot;created_at&quot;:&quot;2020-01-06 19:59:53&quot;,&quot;updated_at&quot;:&quot;2020-01-06 19:59:53&quot;},{&quot;id&quot;:3,&quot;event_id&quot;:1,&quot;date&quot;:&quot;2020-02-02 00:00:00&quot;,&quot;created_at&quot;:&quot;2020-01-06 19:59:53&quot;,&quot;updated_at&quot;:&quot;2020-01-06 19:59:53&quot;},{&quot;id&quot;:4,&quot;event_id&quot;:1,&quot;date&quot;:&quot;2020-02-03 00:00:00&quot;,&quot;created_at&quot;:&quot;2020-01-06 19:59:53&quot;,&quot;updated_at&quot;:&quot;2020-01-06 19:59:53&quot;}],&quot;favorites&quot;:[],&quot;priceranges&quot;:[{&quot;id&quot;:1,&quot;event_id&quot;:1,&quot;price&quot;:&quot;12.00&quot;,&quot;created_at&quot;:&quot;2020-01-06 19:59:53&quot;,&quot;updated_at&quot;:&quot;2020-01-06 19:59:53&quot;},{&quot;id&quot;:2,&quot;event_id&quot;:1,&quot;price&quot;:&quot;600.00&quot;,&quot;created_at&quot;:&quot;2020-01-06 19:59:53&quot;,&quot;updated_at&quot;:&quot;2020-01-06 19:59:53&quot;}],&quot;category&quot;:{&quot;id&quot;:1,&quot;name&quot;:&quot;Immersive&quot;,&quot;slug&quot;:&quot;immersive&quot;,&quot;description&quot;:&quot;dxzsxzsx&quot;,&quot;largeImagePath&quot;:&quot;category-large-images\/immersive.jpeg&quot;,&quot;thumbImagePath&quot;:&quot;category-thumb-images\/thumb-immersive.jpeg&quot;,&quot;created_at&quot;:&quot;2020-01-06 19:54:02&quot;,&quot;updated_at&quot;:&quot;2020-01-06 19:54:02&quot;},&quot;organizer&quot;:{&quot;id&quot;:1,&quot;user_id&quot;:1,&quot;name&quot;:&quot;Independant43&quot;,&quot;website&quot;:&quot;http:\/\/www.nolan.com\/ipsam-eius-et-ex-voluptas-sequi-eveniet-nesciunt.html&quot;,&quot;email&quot;:&quot;[email protected]&quot;,&quot;slug&quot;:&quot;independant&quot;,&quot;description&quot;:&quot;Dzsxsxzsx&quot;,&quot;rating&quot;:&quot;0&quot;,&quot;imagePath&quot;:&quot;organizer-images\/independant_organization_22645.jpeg&quot;,&quot;instagramHandle&quot;:&quot;Chris Grim&quot;,&quot;twitterHandle&quot;:null,&quot;facebookHandle&quot;:&quot;Chris Grim&quot;,&quot;created_at&quot;:&quot;2020-01-06 19:55:06&quot;,&quot;updated_at&quot;:&quot;2020-01-07 23:25:17&quot;},&quot;location&quot;:{&quot;id&quot;:1,&quot;event_id&quot;:1,&quot;hiddenLocationToggle&quot;:0,&quot;hiddenLocation&quot;:null,&quot;home&quot;:&quot;600&quot;,&quot;street&quot;:&quot;California Street&quot;,&quot;city&quot;:&quot;San Francisco&quot;,&quot;region&quot;:&quot;California&quot;,&quot;country&quot;:&quot;US&quot;,&quot;postal_code&quot;:94108,&quot;longitude&quot;:&quot;-122.40469050&quot;,&quot;latitude&quot;:&quot;37.79291580&quot;,&quot;created_at&quot;:&quot;2020-01-06 19:59:00&quot;,&quot;updated_at&quot;:&quot;2020-01-06 19:59:14&quot;}}">

This seems like a bit of an issue with security. I almost want to just use an axios GET in vue to call the data instead of binding it. Is there anyway to pass the data from the Laravel blade into Vue without exposing everything like this?

Jan
09
2 weeks ago
Activity icon

Replied to Verification Emails Not Working With SMTP

I realized mine was getting caught in gmails spam filter because it looked dangerous.

Activity icon

Replied to Verification Emails Not Working With SMTP

I am having this issue too when doing it on my server. With maitrap I see that the email is coming form

Example <[email protected]e.com>

How would I change that? Could it be causing it to get caught?

Jan
06
2 weeks ago
Activity icon

Replied to How To Pass Vue Returned Data Correctly In Template

@sti3bas One quick question. How do you deal with if they click the button again to close the popup? I originally use

@click = "showprice = !showprice
Activity icon

Replied to How To Pass Vue Returned Data Correctly In Template

Amazing! That is exactly what I was looking for.

Activity icon

Started a new Conversation How To Pass Vue Returned Data Correctly In Template

Hi, I have 4 different popups money, dates, time, category. With each of these popup divs I have a v-if to show it.

<div v-if="showTime">
time content here
</div>
<div v-if="showDates">
dates content here
</div>
<div v-if="showMoney">
money content here
</div>
<div v-if="showCategory">
category content here
</div>

then in my returned data I have

showTime: false,
showCategory: false,
showDates: false,
showMoney: false,

I am setting up my buttons one way but I am sure its wrong and I would love to know the correct way.

<button @click="onShowMoney()"> Show Money</button>
<button @click="onShowDates()"> Show Dates</button>
<button @click="onShowTime()"> Show Time</button>
<button @click="onShowCategory()"> Show Category</button>

methods: {
    
    onShowMoney() {
        this.showMoney = true;
        this.showTime = false;
        this.showDates = false;
        this.showCategory = false;
}

    onShowDates() {
        etc...
}
}

There must be a simpler, cleaner way to hide the other popups and show the correct one on click. Thanks!

Jan
03
3 weeks ago
Activity icon

Awarded Best Reply on Struggling With OnClose Config In Returned Data

I finally did it this way

onClose: [this.makeFunction()]

and

methods: {
  ...
  makeFunction() {
    // Save component this in that
    const that = this;
    // return function needed
    return function(value) {
        const dateArr = value.map(date => 
            this.formatDate(date, "Y-m-d H:i:s"));
         console.log(dateArr);
         that.dates = dateArr;
        }
    }
Activity icon

Replied to Struggling With OnClose Config In Returned Data

I finally did it this way

onClose: [this.makeFunction()]

and

methods: {
  ...
  makeFunction() {
    // Save component this in that
    const that = this;
    // return function needed
    return function(value) {
        const dateArr = value.map(date => 
            this.formatDate(date, "Y-m-d H:i:s"));
         console.log(dateArr);
         that.dates = dateArr;
        }
    }
Activity icon

Started a new Conversation Struggling With OnClose Config In Returned Data

Hi All, I'm really struggling to get my head around an issue. I am using a flatpickr vue plugin and he has it setup so the onClose is done through the config in the data.

data() {
            return {
                dates: [],
                config: {
                    minDate: "today",
                    showMonths: 2,
                    dateFormat: 'Y-m-d H:i:s',
                    onClose: [function(value) {
                        const dateArr = value.map(date => 
                        this.formatDate(date, "Y-m-d H:i:s"));
                        console.log(dateArr);
                        this.datesSubmit = dateArr;
                    }] 
                },
            }
        },

I'm really stuck because in order to use the formatDate method it has to be setup as

function(value)

The only problem is it doesn't have access to this.datesSubmit to save the data onClose. If I try to use an arrow

(value) => {

Then it gives me the error that there is no formatDate method.

How do I get the dateArr to save to this.datesSubmit onClose??

Dec
31
3 weeks ago
Activity icon

Replied to How Can I Put An If Statement Inside Laravels Blade Brackets?

That worked!! Thanks so much. I forgot the ()

Dec
30
3 weeks ago
Activity icon

Replied to How Can I Put An If Statement Inside Laravels Blade Brackets?

This is data going into the nav bar on every page of my site. Auth() is easily passed to every page without me having to setup a View composer.

Activity icon

Started a new Conversation How Can I Put An If Statement Inside Laravels Blade Brackets?

I want to do something like

{{ auth()->user() ? auth()->user()->name : 'dennis'

but that doesn't work. Is there a way to do this without doing the

@if 

Im asking because I have

<vue-nav
        username="{{ auth()->user()->name }}"
        userid="{{auth()->id()}}"
        avatar="{{ auth()->user()->avatar_path }}"
        usertype="{{ if(auth()->user()->userType) {auth()->user()->userType->name} else {'user'} }}"
        createdevents="{{ auth()->user()->hasCreatedOrganizers }}"> </vue-nav>

and I'd prefer not to duplicate that entire chunk of text, just the one line.

Activity icon

Replied to Laravel To Vue Auth Not Prop Binding Correctly

Oh man, The more I learn the more I realize I have to learn. Thanks so much.

Activity icon

Started a new Conversation Laravel To Vue Auth Not Prop Binding Correctly

Hi, If I try to bind the prop

<vue-nav :username="{{ Auth::user()->name }}"></vue-nav>

it gives me an undefined error in Vue

props: {
            username: {
                type:String,
            },

However if I do {{ Auth::user()->name }} in the blade file it shows the user name. Also if I try to pass the user id like

<vue-nav
        :username="{{ Auth::user()->name }}"
        :userid="{{auth()->id()}}">

That does pass into my vue file. Has anyone else had an issue with this?

Dec
29
4 weeks ago
Activity icon

Replied to Laravel Vue Attribute Binding Displaying All Variable In Website Html

Ahh I see, I was passing everything and then just using what I needed in the Vue component. However, I didn't realize that it was visible to the user. I will just pass along the info I need.

Thanks!

Activity icon

Started a new Conversation Laravel Vue Attribute Binding Displaying All Variable In Website Html

Hi, I am using Vue attribute binding to add info to my Vue components. Here is an example

@auth
        <vue-nav :loaduser="{{auth()->user()}}"></vue-nav>
    @endauth

However when I go to the source html of my site I see this

<vue-nav :loaduser="{&quot;id&quot;:1,&quot;name&quot;:&quot;chris&quot;,&quot;email&quot;:&quot;[email protected]&quot;,&quot;email_verified_at&quot;:null,&quot;avatar_path&quot;:null,&quot;image_path&quot;:null,&quot;provider&quot;:null,&quot;provider_id&quot;:null,&quot;type&quot;:&quot;default&quot;,&quot;created_at&quot;:&quot;2019-12-20 08:14:14&quot;,&quot;updated_at&quot;:&quot;2019-12-20 08:14:14&quot;,&quot;stripe_id&quot;:null,&quot;card_brand&quot;:null,&quot;card_last_four&quot;:null,&quot;trial_ends_at&quot;:null,&quot;hasCreatedOrganizers&quot;:true,&quot;userType&quot;:{&quot;id&quot;:1,&quot;user_id&quot;:1,&quot;name&quot;:&quot;admin&quot;,&quot;created_at&quot;:null,&quot;updated_at&quot;:null},&quot;needsApproval&quot;:0}"></vue-nav>

This seems wrong that a user a see all of their info like id etc... Is there a way to hide this data?

Activity icon

Replied to How To Split Up Vue Components?

The 1.1mb is just my js file, no images or text for the site included. So if I get this right, your suggestion is to have two files, like an app.js and applite.js. And on the home page the applite.js with just the essential components is loaded and then on all the other pages it yields the app.js file instead with the full list of components?

So there is no way to just have the components stand alone in a different file? That way I could put it at the bottom of the fast loading pages.

Activity icon

Started a new Conversation How To Split Up Vue Components?

Hi, I tried to look this up but couldn't really understand the answers. My app.js file is 1.1 mb and most of that is my components.

//Nav
Vue.component('vue-nav', require('./components/layouts/nav.vue').default);
Vue.component('nav-search', require('./components/layouts/nav-search.vue').default);
Vue.component('profile-button', require('./components/layouts/profile-button.vue').default);
Vue.component('vue-create-nav', require('./components/layouts/create/nav.vue').default);


//Components
Vue.component('favorite', require('./components/layouts/favorite.vue').default);
Vue.component('modal', require('./components/layouts/modal.vue').default);
Vue.component('tabs', require('./components/layouts/tabs.vue').default);
Vue.component('tab', require('./components/layouts/tab.vue').default);
Vue.component('image-upload', require('./components/layouts/image-upload.vue').default);

//Create Events
Vue.component('event-create-checklist', require('./components/create/checklist.vue').default);
Vue.component('create-location-google', require('./components/create/location-google.vue').default);
Vue.component('create-category', require('./components/create/category.vue').default);
Vue.component('create-organizer', require('./components/create/organizer.vue').default);
Vue.component('create-title', require('./components/create/title.vue').default);
Vue.component('create-image', require('./components/create/image.vue').default);
Vue.component('create-date-picker', require('./components/create/datepicker.vue').default);
Vue.component('create-shows', require('./components/create/shows.vue').default);
Vue.component('show-listing', require('./components/create/show-listing.vue').default);
Vue.component('create-description', require('./components/create/description.vue').default);
Vue.component('create-advisories', require('./components/create/advisories.vue').default);

//Admin Area
Vue.component('admin-nav', require('./components/adminArea/nav.vue').default);
Vue.component('approval-bar', require('./components/adminArea/approve/approval-bar.vue').default);
Vue.component('admin-categories', require('./components/adminArea/admin-categories.vue').default);
Vue.component('admin-contact-level', require('./components/adminArea/admin-contact-level.vue').default);
Vue.component('admin-genres', require('./components/adminArea/admin-genres.vue').default);
Vue.component('admin-regions', require('./components/adminArea/admin-regions.vue').default);
Vue.component('admin-content-advisories', require('./components/adminArea/admin-content-advisories.vue').default);

//Profile
Vue.component('user-profile', require('./components/profile/profile-index.vue').default);

//Categories
Vue.component('category-show', require('./components/categories/category-show.vue').default);

//Organizers
Vue.component('organizer-show', require('./components/organizers/organizer-show.vue').default);

//Events
Vue.component('event-index', require('./components/events/event-index.vue').default);
Vue.component('search-listing', require('./components/events/event-search.vue').default);
Vue.component('event-show', require('./components/events/event-show.vue').default);
Vue.component('edit-events', require('./components/events/event-edit.vue').default);
Vue.component('event-listing-item', require('./components/events/components/index-item.vue').default);

I only need a few of these components on my initial page load so I was hoping there was a way I could break them into a seperate js file which I can include when the user loads a page that needs those extra files (mostly the admin and create components).

Dec
18
1 month ago
Activity icon

Replied to How To Deal With The Back Button In Vue?

I am actually happy that it doesnt work :)

Dec
16
1 month ago
Activity icon

Replied to How To Deal With The Back Button In Vue?

Actually I decided to just rewrite all my code and instead of using a prop to bind the data I am using a mounted() axios get request. Not as clean looking but it always gets the latest data even if the user presses the back button.

Activity icon

Replied to How To Deal With The Back Button In Vue?

@willvincent I guess I was thinking I might do the popup saying your data will be lost if you leave? Does that mess with the user?

Activity icon

Replied to How To Deal With The Back Button In Vue?

Im starting to see that this is actually a pretty big issue! I am going to have to re-look at how I set it up. I was thinking that I could just do

mounted(){
    //axios get call here to get data
}

but if the user presses the back button for some reason the data I get from axios is actually old

Activity icon

Replied to How To Deal With The Back Button In Vue?

@fylzero That doesn't seem to work sadly. I am thinking the only way to deal with this is just to do an axios get everytime the page loads instead of trying to bind the data through laravel.

Dec
15
1 month ago
Activity icon

Replied to How To Deal With The Back Button In Vue?

@jlrdw Is there not a simple way to detect the back button without having to store something?

Activity icon

Replied to How To Deal With The Back Button In Vue?

Hi @bobbybouwmann

I tried adding this but from what I can see document.addEventListener("backbutton" only works on devices? When I press back it doesn't fire the method.

Activity icon

Started a new Conversation How To Deal With The Back Button In Vue?

I've noticed in my vue/laravel project that if I press the back button on the browser it doesn't repopulate my data. What is the simplest way/most browser compatible to watch for a browser back button and run an axios to fetch the latest data?

Thanks!

Dec
11
1 month ago
Activity icon

Replied to Best Way To Check For Stacking Multiple Fields

So simple! I was definitely trying to over complicate it.

Activity icon

Replied to When To Add A Row Vs When To Add A New Model

Thanks! That helps make sense!

Activity icon

Started a new Conversation When To Add A Row Vs When To Add A New Model

This is more of a database question but I figured I would ask it anyways. I am trying to understand when to add a column to a table vs when to create a new model and use a belongsTo. I want to understand best practices when it comes to setting up my database. I have an event table like so

Schema::create('events', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->unsignedBigInteger('user_id');
            $table->unsignedBigInteger('category_id')->nullable();
            $table->unsignedBigInteger('expectation_id')->nullable();
            $table->unsignedBigInteger('organizer_id')->nullable();
            $table->string('slug')->unique();
            $table->string('name')->nullable();
            $table->longtext('description')->nullable();
            $table->longtext('tag_line')->nullable();
            $table->string('websiteUrl')->nullable();
            $table->string('show_times')->nullable();
            $table->string('ticketUrl')->nullable();
            $table->string('largeImagePath')->nullable();
            $table->string('thumbImagePath')->nullable();
            $table->string('overallRating')->default(0);
            $table->json('location_latlon')->nullable();
            $table->dateTime('closingDate')->nullable();
            $table->string('price_range')->nullable();
            $table->string('approval_process')->default('inProgress');
            $table->boolean('approved')->default(0);
            $table->timestamps();
        });

I just realized that moderators on my site are going to have to not just approve/disapprove the event but also give comments about what was wrong. So should I just add a new longtext column

$table->longtext('moderator_comments')->nullable();

or would I create a new model ModeratorComments and use a hasOne / belongsTo relationship? How do I know when I have used too many columns? Thanks so much for any help.

Dec
10
1 month ago
Activity icon

Started a new Conversation Best Way To Check For Stacking Multiple Fields

Hi, I am setting up the ability for a user to jump to anywhere in their event creation process. I have an event model that is filled as the user creates the event page by page. I am trying to figure out the best way to look at that model and redirect the user to the correct url.

Right now I am using computed methods but I can't get this to work

pageLoad() {
                return this.event.category_id ? 'category' : 
                        (this.event_latlon ? 'location' : 
                            (this.event.title ? 'title' : ''))
            },
url() {
                return `/create-event/${this.event.slug}/${this.pageLoad}`;
            }

Is there a better way to do this? Thanks!

Dec
03
1 month ago
Activity icon

Replied to Is There A Cleaner Way To Write This Code

Wow! This is amazing!!! Thanks so much for taking the time to explain it deeper.

Activity icon

Replied to Is There A Cleaner Way To Write This Code

That makes so much more sense ha! I will add live, past, pending and in_progress to the mode instead of the controller!

Activity icon

Started a new Conversation Is There A Cleaner Way To Write This Code

Hi, I have the following code to load custom searches for events in each organization.

$organizers = auth()->user()->organizers;
        foreach($organizers as $organizer) {
            $eventsbyorganizer[] = [
                'id' => $organizer->id,
                'name' => $organizer->name,
                'slug' => $organizer->slug,
                'imagePath' => $organizer->imagePath,
                'live_events' =>  Event::search('*')
                    ->where('closingDate', '>=', 'now/d')
                    ->where('user_id', auth()->user()->id)
                    ->where('organizer_id', $organizer->id)
                    ->get(),
                'past_events' => Event::search('*')
                    ->where('closingDate', '<=', 'now/d')
                    ->where('user_id', auth()->user()->id)
                    ->where('organizer_id', $organizer->id)
                    ->get(),
                'pending_events' => auth()
                    ->user()
                    ->events()
                    ->where('approval_process', 'ready')
                    ->where('organizer_id', $organizer->id)
                    ->get(),
                'in_progress_events' => auth()
                    ->user()
                    ->events()
                    ->where('approval_process', 'inProgress')
                    ->where('organizer_id', $organizer->id)
                    ->get(),
            ];
        }
        return view('events.edit', compact('eventsbyorganizer'));

I feel like I should be doing something with eager loading, but I am not sure how I would do that with specific searches like I am doing. Is there a better way to load this?