chrisgrim

chrisgrim

at Self Employed

Member Since 2 Years Ago

Petaluma

Experience Points
30,790
Total
Experience

4,210 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
137
Lessons
Completed
Best Reply Awards
0
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 7
30,790 XP
Aug
04
5 days ago
Activity icon

Replied to Adding A Column To Existing Database And Using Laravel To Fill In Field

Gotcha, yeah was just wondering if there was anything set in place in case it was a little more complicated than just updating the status to p

Activity icon

Replied to Adding A Column To Existing Database And Using Laravel To Fill In Field

Hi @michaloravec My structure is

 public function up()
    {
        Schema::create('organizers', function (Blueprint $table) {
            $table->id();
            $table->foreignId('user_id');
            $table->string('name');
            $table->string('website')->nullable();
            $table->string('email')->nullable();
            $table->string('slug')->unique();
            $table->text('description');
            $table->string('rating')->default(0);
            $table->string('largeImagePath')->nullable();
            $table->string('thumbImagePath')->nullable();
            $table->string('instagramHandle')->nullable();
            $table->string('twitterHandle')->nullable();
            $table->string('facebookHandle')->nullable();
            $table->char('type', 1)->default('o');
            $table->timestamps();
        });
    }

So I would have to run a mysql update, nothing I can do through laravel?

Activity icon

Started a new Conversation Adding A Column To Existing Database And Using Laravel To Fill In Field

Hi, I am using

php artisan make:migration add_status_to_organizers_table --table=organizers

to add a status column to my organizers model. I already have around 200 organizers in my live app. In my migration file I have

public function up()
    {
        Schema::table('organizers', function (Blueprint $table) {
            $table->char('status', 1)->default('d');
        });
    }
public function down()
    {
        Schema::table('organizers', function (Blueprint $table) {
            $table->dropColumn('status');
        });
    }

Is there any way that I can set it up so that when I run php artisan migrate it will look at each model and if the current date is older than todays date it will set the status to 'p'. Then any new organizers created after will have a default status of 'd'?

Activity icon

Replied to How To Deal With Capitalization FirstOrCreate Issue

@geordiejackson I didn't even think about this way but it makes a lot of sense! Thanks so much.

Activity icon

Replied to How To Deal With Capitalization FirstOrCreate Issue

Hi @marianomoreyra What happens in a situation where the user adds 'At PM' and I have 'At Pm'?

Activity icon

Started a new Conversation How To Deal With Capitalization FirstOrCreate Issue

Hi, I am allowing users to select or create their own genres for their event. When they enter their list of genres I add it using:

if ($request->has('genre')) {
            foreach ($request['genre'] as $genre) {
                Genre::firstOrCreate([
                    'name' => strtolower($genre)
                ],
                [
                    'user_id' => auth()->user()->id,
                ]);
            };
            $newSync = Genre::all()->whereIn('name', array_map('strtolower', $request['genre']));
            $event->genres()->sync($newSync);
        };

The reason I am doing Strtolower is because I discovered that laravel sees the words and 'test' and 'Test' as two different words and will allow both of them. Using strtolower fixes this by making everything the same capitalization but I realized that I don't like having everything lower case. Is there an easy way around this?

Jul
20
2 weeks ago
Activity icon

Replied to Setting Up A Relationship

Hi @glenuk Thanks so much for the response!

I tested out your method and it worked for getting me the first response where the subject is english. But how do I get a collection of all of the users conversations with messages that contain the subject english?

Activity icon

Started a new Conversation Setting Up A Relationship

Hi, I have 3 models. A User, Conversation, and a Message model. In my User model I have

/**
     * The User belongs to many Conversations
     *
     * @return \Illuminate\Database\Eloquent\Relations\hasMany
     */
    public function conversations()
    {
        return $this->belongsToMany(Conversation::class)->orderBy('updated_at', 'DESC');
    }

and then in my Conversation model I want to do something like

/**
     * These Conversations have Messages to do with English
     *
     * @return \Illuminate\Database\Eloquent\Relations\hasMany
     */

    public function english()
    {
        return $this->hasMany(Message::class)->where('subject', 'english');
    }

Is there a way to do

$user->conversations()->english()->get();

Right now I am getting the error Call to undefined method Illuminate\Database\Eloquent\Relations\BelongsToMany::english()

Jul
17
3 weeks ago
Activity icon

Replied to Trying To Figure Out A Relationship

Hi @bugsysha The eventmessage is for admin approval or requests to user submitted events. My migration tables for messages and eventmessages are pretty similar. Eventmessage

Schema::create('moderator_comments', function (Blueprint $table) {
            $table->id();
            $table->foreignId('user_id');
            $table->foreignId('event_id');
            $table->foreignId('conversation_id');
            $table->text('comments');
            $table->timestamps();
            $table->foreign('event_id')
                    ->references('id')->on('events')
                    ->onDelete('cascade');
        });

Message:

Schema::create('messages', function (Blueprint $table) {
            $table->id();
            $table->foreignId('user_id');
            $table->foreignId('conversation_id');
            $table->text('message');
            $table->timestamps();
            $table->foreign('conversation_id')
                    ->references('id')->on('conversations')
                    ->onDelete('cascade');
        });

Would the better technique have been to only have one message model, but have a column for message type and make the event_id column nullable?

Activity icon

Started a new Conversation Trying To Figure Out A Relationship

Hi, I have created a messaging system for my project. I have a conversations model, a messages model, an eventmessages model. In my conversation model I have:

 /**
     * This Conversation has many Messages
     *
     * @return \Illuminate\Database\Eloquent\Relations\hasMany
     */

    public function messages()
    {
        return $this->hasMany(Message::class)->orderBy('updated_at', 'DESC');
    }

    /**
     * This Conversation has many event notices
     *
     * @return \Illuminate\Database\Eloquent\Relations\hasMany
     */

    public function eventmessages()
    {
        return $this->hasMany(ModeratorComment::class)->orderBy('updated_at', 'DESC');
    }

then in both the messages and eventmessages models I have:

    /**
     * This Conversation has many event notices
     *
     * @return \Illuminate\Database\Eloquent\Relations\hasMany
     */

    public function conversation()
    {
        return $this->belongsTo(Conversation::class);
    }

    /**
    * Each comment belongs to one user
    *
    * @return \Illuminate\Database\Eloquent\Relations\belongsTo
    */
    public function user() 
    {
        return $this->belongsTo(User::class);
    }

I also have a conversation_user pivot table with both being belongToMany

I am trying to get all of the conversations that include the user and the eventmessages. I originally had

$allmessages = auth()->user()->conversations()->get();

but I realized that if there are hundreds of conversations and I want to limit it to 10 or 20 to show more, then there is no way for me to separate it into messages and eventmessages. I can do it the roundabout way of

$all = auth()->user()->eventmessages()->pluck('conversation_id');
return Conversation::find($all);

but it doesn't seem like the clean Laravel way.

Thanks!

Jul
16
3 weeks ago
Activity icon

Replied to Vue Import Chunks Cache Busting

@j5dev I have one more question. Sorry to bother you but its amazing to have found such a great resource. I set it up like you said

//Nav
Vue.component('vue-nav', () => import(/* webpackChunkName: "assets/ls" */ './pages/layouts/nav.vue'));
Vue.component('nav-search', () => import(/* webpackChunkName: "assets/lns" */ './pages/layouts/nav-search.vue'));
Vue.component('profile-button', () => import(/* webpackChunkName: "assets/lp" */ './pages/layouts/profile-button.vue'));
//Footer
Vue.component('vue-footer', () => import(/* webpackChunkName: "assets/lfo" */ './pages/layouts/footer.vue'));
//Components
Vue.component('favorite', () => import(/* webpackChunkName: "assets/lf" */ './pages/layouts/favorite.vue'));
Vue.component('modal', () => import(/* webpackChunkName: "assets/lm" */ './pages/layouts/modal.vue'));
Vue.component('tabs', () => import(/* webpackChunkName: "assets/lts" */ './pages/layouts/tabs.vue'));
Vue.component('tab', () => import(/* webpackChunkName: "assets/lt" */ './pages/layouts/tab.vue'));
Vue.component('image-upload', () => import(/* webpackChunkName: "assets/liu" */ './pages/layouts/image-upload.vue'));
Vue.component('vue-alert', () => import(/* webpackChunkName: "assets/la" */ './pages/layouts/alert.vue'));
Vue.component('vue-email-verify', () => import(/* webpackChunkName: "assets/lev" */ './pages/layouts/email-verified.vue'));
//Create Events
Vue.component('vue-create-nav', () => import(/* webpackChunkName: "assets/cn" */ './pages/create/nav.vue'));
Vue.component('vue-create-organizer-nav', () => import(/* webpackChunkName: "assets/con" */ './pages/create/organizer-nav.vue'));
Vue.component('vue-create-nav-bottom-bar', () => import(/* webpackChunkName: "assets/cbn" */ './pages/create/nav-bottom-bar.vue'));
Vue.component('create-location-google', () => import(/* webpackChunkName: "assets/cl" */ './pages/create/location-google.vue'));
Vue.component('create-category', () => import(/* webpackChunkName: "assets/cc" */ './pages/create/category.vue'));
Vue.component('create-organizer', () => import(/* webpackChunkName: "assets/co" */ './pages/create/organizer.vue'));
Vue.component('create-title', () => import(/* webpackChunkName: "assets/ct" */ './pages/create/title.vue'));
Vue.component('create-image', () => import(/* webpackChunkName: "assets/ci" */ './pages/create/image.vue'));
Vue.component('create-date-picker', () => import(/* webpackChunkName: "assets/cd" */ './pages/create/datepicker.vue'));
Vue.component('create-shows', () => import(/* webpackChunkName: "assets/cs" */ './pages/create/shows.vue'));
Vue.component('vue-create-tickets', () => import(/* webpackChunkName: "assets/ct" */ './pages/create/tickets.vue'));
Vue.component('show-listing', () => import(/* webpackChunkName: "assets/csl" */ './pages/create/show-listing.vue'));
Vue.component('create-description', () => import(/* webpackChunkName: "assets/cd" */ './pages/create/description.vue'));
Vue.component('create-advisories', () => import(/* webpackChunkName: "assets/ca" */ './pages/create/advisories.vue'));
Vue.component('vue-create-review-event', () => import(/* webpackChunkName: "assets/cre" */ './pages/create/review-event.vue'));
Vue.component('vue-create-first-event', () => import(/* webpackChunkName: "assets/cs" */ './pages/create/start-event-creation.vue'));
//Admin Area
Vue.component('admin-nav', () => import(/* webpackChunkName: "assets/an" */ './pages/adminArea/nav.vue'));
Vue.component('approval-bar', () => import(/* webpackChunkName: "assets/aab" */ './pages/adminArea/approve/approval-bar.vue'));
Vue.component('approval-list', () => import(/* webpackChunkName: "assets/al" */ './pages/adminArea/approve/approval-list.vue'));
Vue.component('admin-categories', () => import(/* webpackChunkName: "assets/ac" */ './pages/adminArea/admin-categories.vue'));
Vue.component('admin-contact-level', () => import(/* webpackChunkName: "assets/acl" */ './pages/adminArea/admin-contact-level.vue'));
Vue.component('admin-genres', () => import(/* webpackChunkName: "assets/ag" */ './pages/adminArea/admin-genres.vue'));
Vue.component('vue-admin-events', () => import(/* webpackChunkName: "assets/ae" */ './pages/adminArea/admin-events.vue'));
Vue.component('vue-admin-boneyard', () => import(/* webpackChunkName: "assets/ab" */ './pages/adminArea/admin-boneyard.vue'));
Vue.component('vue-admin-stats', () => import(/* webpackChunkName: "assets/as" */ './pages/adminArea/admin-stats.vue'));
Vue.component('admin-event-reviews', () => import(/* webpackChunkName: "assets/aer" */ './pages/adminArea/admin-event-reviews.vue'));
Vue.component('admin-staff-picks', () => import(/* webpackChunkName: "assets/ap" */ './pages/adminArea/admin-staff-picks.vue'));
Vue.component('admin-mobility', () => import(/* webpackChunkName: "assets/am" */ './pages/adminArea/admin-mobility.vue'));
Vue.component('admin-regions', () => import(/* webpackChunkName: "assets/ar" */ './pages/adminArea/admin-regions.vue'));
Vue.component('admin-user', () => import(/* webpackChunkName: "assets/au" */ './pages/adminArea/admin-user.vue'));
Vue.component('admin-organizer', () => import(/* webpackChunkName: "assets/ao" */ './pages/adminArea/admin-organizer.vue'));
Vue.component('admin-content-advisories', () => import(/* webpackChunkName: "assets/aca" */ './pages/adminArea/admin-content-advisories.vue'));
Vue.component('vue-admin-remote-locations', () => import(/* webpackChunkName: "assets/arl" */ './pages/adminArea/admin-remote-locations.vue'));
Vue.component('vue-admin-interactive-levels', () => import(/* webpackChunkName: "assets/ail" */ './pages/adminArea/admin-interactive-levels.vue'));

and then in my webpack mix

require('laravel-mix-merge-manifest');

mix.js('resources/js/app.js', 'public/assets')
    .extract(['vue','vuelidate','leaflet','vuelidate-error-extractor','vue-cookies'])
    .mergeManifest()
    .webpackConfig({
    output: {
        chunkFilename: '[name].js?id=[chunkhash]',
    }
});


if (mix.inProduction()) {
    mix.version();
}

its working but it created some really bizarre files. It created a vendors~assets folder and inside there are folders named liked ae~assets, ab~assets that have folders inside them named al~assets and this continues like a russian doll for like 7 levels! Each one ends in files named like cs~a~35f921f5.js. Even weirder to me is there are only like 7, so it isn't doing this for every single one of my files. If I go into my assets folder I see all the ae.js and ab.js files like normal. I did a test and discovered that my site is actually using the ae~assets/cs~a~353434da.js files. This is a bit beyond my level of knowledge. Do you know what is happening?

Jul
15
3 weeks ago
Activity icon

Replied to Vue Import Chunks Cache Busting

Wow this is amazing! Thank you so much!!!

Jul
14
3 weeks ago
Activity icon

Replied to Vue Import Chunks Cache Busting

Hi @j5dev This is great! thanks so much for showing me this. In my blade file I have to use mix to pull in the hashed file

<link href="{{ mix('/assets/app-create.css') }}" rel="stylesheet">

Does Vue do this automatically with what you showed me or do I have to change anything to use the latest chunk?

Activity icon

Started a new Conversation Struggling Creating My Own Validations For A V-for Form Submission

I am using Vuelidate to validate my project but I was having a lot of issues with trying to validate my v-for. So I decided to do my own validation just for the v-for. I am having an issue trying to recreate some of the aspect and I would love to know if I am doing it wrong and if there is a better way.

When a user creates a new item I do

initializeTicketObject() {
            return {
                id: '',
                name: '',
                show_id: '',
                ticket_amount: '',
                ticket_price: '',
                errors: this.initializeErrorObject(),
            }
        },
 initializeErrorObject() {
            return [
                { name:'priceLength', type:'price', hasError: false},
                { name:'priceEmpty', type:'price', hasError: false},
                { name:'nameEmpty', type:'name', hasError: false},
                { name:'nameLength', type:'name', hasError: false},
                { name: 'nameRepeat', type:'name', hasError: false }, 
                { name: 'descriptionLength', type:'description', hasError: false }, 
            ]
        },

then when they submit I am doing its still WIP


onSubmit(value) {
            let previous = [];
            for (var i = 0; i < this.tickets.length; i++) {
                if (this.tickets[i].ticket_price == 0.00 && this.tickets[i].type.type == 's') {
                    // change priceEmpty hasError to true
                        return false;
                }
                if (this.tickets[i].ticket_price.length > 3 && this.tickets[i].type.type == 's') {
                    // change priceLength hasError to true
                        return false;
                }
                if (previous.includes(this.tickets[i].name.toLowerCase())) {
                    // change ticketLength hasError to true
                    return false;
                }
                previous.push(this.tickets[i].name.toLowerCase())
            }

Then the part I am struggling with is showing it in the input

<div v-for="(ticket, index) in tickets" class="ticket-box__element grid">
<div v-else class="field">
                                    <input 
                                    v-model="ticket.ticket_price"
                                    v-money="money"
                                    :class="{ active: active == `price${index}`, error: showErrors(ticket) }"
                                    @click="active = `price${index}`"
                                    @blur="active = null"
                                    @keyup="reset"
                                    placeholder="LARACASTS_SNIPPET_PLACEHOLDER.00"
                                    v-bind="money"
                                    @keydown="$event.key === '-' ? $event.preventDefault() : null"
                                    style="text-align: right" 
                                    />
                                    <div v-if="what check here?" class="validation-error">
                                        <p class="error">Can't be zero</p>
                                    </div>
                                    <div v-if="what check here?" class="validation-error">
                                        <p class="error">Price is too big</p>
                                    </div>
                                </div>

I guess I was hoping to know if this format is the best way to do it and if I should be saving the errors as a list of objects in an array or of there is a cleaner simpler way?

Activity icon

Replied to Get Value Of Object From Foreach Array?

When I see {} I assume object

Jul
13
3 weeks ago
Activity icon

Replied to Get Value Of Object From Foreach Array?

Why did it show it as an object?

Activity icon

Replied to Get Value Of Object From Foreach Array?

After a lot of searching I discovered that I needed to do

$ticket['type']['name']

Thanks!

Activity icon

Replied to Get Value Of Object From Foreach Array?

If I just return $ticket I get

description: null
name: "Senior"
ticket_price: "333.00"
type:
    name: "normal"
    type: "s"
__proto__: Object
__proto__: Object
Activity icon

Replied to Get Value Of Object From Foreach Array?

It is always an object. If I try to do that it just stores the object in my database. {"name":"normal","type":"s"} that is in my table under type.

Activity icon

Replied to Get Value Of Object From Foreach Array?

Hi @michaloravec Thanks so much for the quick response. I am very confused now. If I do a

 foreach ($request->tickets as $ticket) {
                return $ticket['type'];
            }

I get

{name: "normal", type: "s"}

However if I do

            foreach ($request->tickets as $ticket) {
                return $ticket['type']->name;
            }

I get

"Trying to get property 'name' of non-object"

What am I doing wrong?

Activity icon

Started a new Conversation Get Value Of Object From Foreach Array?

Hi, I have this foreach

foreach ($request->tickets as $ticket) {
                 $show->tickets()->updateOrCreate([
                    'name' => $ticket['name'],
                ],
                [
                    'description' => $ticket['description'],
                    'ticket_price' => str_replace('$', '', $ticket['ticket_price']),
                    'type' => $ticket['type']
                ]);
            }

My problem is the $ticket['type'] is actually an object. So if I return $ticket['type'] I get

{id:1, name:'free'}

If I just want to enter free into the type how would I do that? $ticket['type.name'] doesn't work.

Activity icon

Started a new Conversation How To Deal With Vue Calendar Input Issue?

Hi, I am using Vuelidate for validation and flat-pickr for my calendar. One of the things I like about Vuelidate is $anydirty. This shows me if anyone has changed anything if they revisit the submission page. This feature works great with normal inputs however with flat-pickr when it adds their previous data on pageload it triggers the $anydirty so it looks like they have entered something into the calendar. Has anyone else dealt with something like this? Is there a way to add a delay so the input isn't triggered until after?

<flat-pickr
                                    v-model="startDate"
                                    :config="embargoCalendarConfig"
                                    ref="datePicker"                                              
                                    class="form-control"
                                    @input="$v.$touch"
                                    placeholder="Select date"    
                                    name="dates">
                                </flat-pickr>

that is my calender code. The @input is what triggers the calendar.

Jul
06
1 month ago
Activity icon

Replied to Soft Delete Return On Show Method

Gotcha @snapey Ok thanks

Activity icon

Started a new Conversation Soft Delete Return On Show Method

Hi, I am trying to access a soft deleted model using a show method and running into an issue. If I use

 public function show(Conversation $conversation)
{
return $conversation->withTrashed();
}

then it throws an error message saying there is no page when the conversation has been deleted. However, if I do

 public function show($conversation)
{
return Conversation::where('id', $conversation)->withTrashed()->get();
}

it works. Is there a way I can have the first way work so I can use the laravel magic? Thanks

Jul
02
1 month ago
Activity icon

Replied to Unsupported Image Type. GD Driver Is Only Able To Decode JPG, PNG, GIF Or WebP Files

I have installed it on both and ran

php -r 'echo "imagick is ".(extension_loaded("imagick")?"":"not ")."installed\n";'

and it says imagick is installed

Activity icon

Replied to Unsupported Image Type. GD Driver Is Only Able To Decode JPG, PNG, GIF Or WebP Files

I guess what I dont understand is that I switched my driver to imagick and yet I am still getting the

GD driver is only able to decode JPG

error in my log whenever I try to upload

Activity icon

Replied to Unsupported Image Type. GD Driver Is Only Able To Decode JPG, PNG, GIF Or WebP Files

@michaloravec

Even if I put my memory_limit to -1 and my upload_max_filesize to 128MB?

Activity icon

Replied to Unsupported Image Type. GD Driver Is Only Able To Decode JPG, PNG, GIF Or WebP Files

@michaloravec I installed Imagick and created a config file for image that said to use imagick. Then cleared my config cache and still I am getting the ND error. Am I missing a step?

Activity icon

Started a new Conversation Unsupported Image Type. GD Driver Is Only Able To Decode JPG, PNG, GIF Or WebP Files

Hi, I am using image Intervention to save images and resize them. I discovered this error when trying to use my same code on my server. It worked fine locally but errored out on the server. Following instructions online I changed my memory_limit = -1 and that seemed to work. However, just today I started getting the same error in my logs

[2020-07-02 18:18:14] production.ERROR: Unsupported image type. GD driver is only able to decode JPG, PNG, GIF or WebP files. {"userId":1,"exception":"[object] (Intervention\Image\Exception\NotReadableException(code: 0): Unsupported image type. GD driver is only able to decode JPG, PNG, GIF or WebP files. at /var/www/html/ei/vendor/intervention/image/src/Intervention/Image/Gd/Decoder.php:59)
[stacktrace]

I haven't changed any of the code and I checked the memory_limit is still -1. I am currently downloading a lot of data so I thought maybe that could be causing it, but I still don't want other users to experience this if they have limited bandwidth as well. I timed how long after I tried uploading I got the 500 error and it was 6 seconds. So I tried changing my max_execution_time = -1 and max_input_time = 60 but it still errors out after 6 seconds which seems strange to me. Can anyone see anything I am missing? I am currently trying with a 5.7 mb image file that works fine when I try to upload to my local. If I try to use a smaller image around 200k that also works fine on my server. It is only when I try to upload the big image to my server.

Jun
30
1 month ago
Activity icon

Replied to Stuggling To Really Understand Middleware

Yeah it was wide open! I couldn't wrap my head around the concept of where vs an instance of the user until now. I see that I already have the user and can just access the needed information. Using a where() on the user doesn't make sense at all now that I understand it.

Activity icon

Replied to Stuggling To Really Understand Middleware

@tykus OMG this whole time that was my issue! THANK YOU so much!!

Activity icon

Started a new Conversation Stuggling To Really Understand Middleware

Hi, I am struggling to understand my middleware. I am trying to setup a moderator area. In my controller I have

    public function __construct()
    {
        $this->middleware('moderator');
    }

and in my kernel I have

'moderator' => \App\Http\Middleware\IsModerator::class,

and for my middleware I have

<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Support\Facades\Auth;

class IsModerator
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        if (Auth::user() && Auth::user()->isModerator()) {
            return $next($request);
        }

        return redirect('/');
    }
}

and in my user model I have

public function isModerator() {
        return $this->where('type', 'm')->orWhere('type', 'a')->exists();
    }

However this currently allows anyone to see the page, even if they are type 'g' and not type 'm' or 'a'. I was thinking that the middleware just wasn't working but if I change it to

if (Auth::user() && Auth::user()->isModerator()) {
            return return redirect('/');
        }

        return redirect('/');

it will actually catch me and return me to the home page. What am I doing wrong?

Jun
29
1 month ago
Activity icon

Replied to Added Doctrine/dbal And It Downgraded A Bunch Of My Laravel Stuff

composer update did the trick! I guess maybe I was using an old one?

Jun
28
1 month ago
Activity icon

Started a new Conversation Added Doctrine/dbal And It Downgraded A Bunch Of My Laravel Stuff

Hi All, I just did composer require doctrine/dbal so I could modify a column on a live database. When I did it I noticed that it downgraded a bunch of things

- Downgrading guzzlehttp/guzzle (6.5.4 => 6.5.3): Downloading (100%)
  - Downgrading aws/aws-sdk-php (3.140.1 => 3.138.2): Downloading (100%)
  - Downgrading symfony/event-dispatcher-contracts (v2.1.2 => v2.0.1): Loading from cache
  - Downgrading symfony/event-dispatcher (v5.1.0 => v5.0.8): Downloading (100%)
  - Downgrading voku/portable-ascii (1.5.1 => 1.4.10): Loading from cache
  - Downgrading vlucas/phpdotenv (v4.1.6 => v4.1.5): Downloading (100%)
  - Downgrading symfony/css-selector (v5.1.0 => v5.0.8): Downloading (100%)
  - Downgrading symfony/var-dumper (v5.1.0 => v5.0.8): Downloading (100%)
  - Downgrading symfony/routing (v5.1.0 => v5.0.8): Downloading (100%)
  - Downgrading symfony/process (v5.1.0 => v5.0.8): Downloading (100%)
  - Downgrading symfony/mime (v5.1.0 => v5.0.8): Downloading (100%)
  - Downgrading symfony/http-foundation (v5.1.0 => v5.0.8): Downloading (100%)
  - Downgrading symfony/error-handler (v5.1.0 => v5.0.8): Downloading (100%)
  - Downgrading symfony/debug (v4.4.9 => v4.4.8): Downloading (100%)
  - Downgrading symfony/http-kernel (v5.1.0 => v5.0.8): Downloading (100%)
  - Downgrading symfony/finder (v5.1.0 => v5.0.8): Downloading (100%)
  - Downgrading symfony/service-contracts (v2.1.2 => v2.0.1): Loading from cache
  - Downgrading symfony/console (v5.1.0 => v5.0.8): Downloading (100%)
  - Downgrading doctrine/lexer (1.2.1 => 1.2.0): Loading from cache
  - Downgrading opis/closure (3.5.3 => 3.5.1): Loading from cache
  - Downgrading symfony/translation-contracts (v2.1.2 => v2.0.1): Loading from cache
  - Downgrading symfony/translation (v5.1.0 => v5.0.8): Downloading (100%)
  - Downgrading nesbot/carbon (2.35.0 => 2.34.0): Downloading (100%)
  - Downgrading monolog/monolog (2.1.0 => 2.0.2): Loading from cache
  - Downgrading league/flysystem (1.0.69 => 1.0.68): Downloading (100%)
  - Downgrading doctrine/inflector (2.0.3 => 2.0.1): Downloading (100%)
  - Downgrading laravel/framework (v7.14.1 => v7.11.0): Downloading (100%)
  - Downgrading laravel/socialite (v4.4.1 => v4.3.2): Loading from cache
  - Downgrading mockery/mockery (1.4.0 => 1.3.1): Loading from cache
  - Downgrading doctrine/instantiator (1.3.1 => 1.3.0): Loading from cache
  - Downgrading phpunit/phpunit (8.5.5 => 8.5.4): Downloading (100%)
  - Downgrading nikic/php-parser (v4.5.0 => v4.4.0): Downloading (100%)
  - Downgrading phpoffice/phpspreadsheet (1.13.0 => 1.12.0): Downloading (100%)
  - Downgrading sabberworm/php-css-parser (8.3.1 => 8.3.0): Loading from cache
  - Downgrading stripe/stripe-php (v7.36.2 => v7.33.1): Downloading (100%)
  - Downgrading symfony/intl (v5.1.0 => v5.0.8): Downloading (100%)
  - Installing doctrine/event-manager (1.1.0): Downloading (100%)
  - Installing doctrine/cache (1.10.1): Downloading (100%)
  - Installing doctrine/dbal (2.10.2): Downloading (100%)

Is this something I have to worry about? After I modify the column should I remove doctrine/dbal and composer update to go back up?

Jun
27
1 month ago
Activity icon

Replied to Issue Submitting That I Think Might Be Cookie Mismatch?

I am going to try sentry.io

Jun
26
1 month ago
Activity icon

Replied to Issue Submitting That I Think Might Be Cookie Mismatch?

Hi @snapey !

Could that be causing my issue you think? Is there a way to check for mismatch and let them know that is why?

Activity icon

Replied to Issue Submitting That I Think Might Be Cookie Mismatch?

@nexxai is Log:: a plugin for vue? How exactly does it work?

Activity icon

Started a new Conversation Issue Submitting That I Think Might Be Cookie Mismatch?

Hi, I am struggling against a problem that I am having a really hard time figuring out. I created a site that allows users to post events. For the most part everyone is able to use it perfectly. However there have been occasions when users aren't able to save data. This is frustrating to trouble shoot because whenever I try to save the data it works perfectly. One of the things I think maybe causing it is a token mismatch. One tester said it happened when she hadn't been on her phone for a while and then opened the site and tried to submit. It didn't work but she said if she refreshed the page then tried to submit again it did work. I am using vue+ axios and a laravel backend. Does this sound like a token issue? She did say remember me. If this is the issue, how do I deal with it? Is there a vue plugin that will check if the tokens match and log you out?

Thanks so much for any help!

Jun
25
1 month ago
Activity icon

Replied to Validation Unique To A Belongs To Model

This is great! Thanks so much for pointing me to the correct docs

Jun
24
1 month ago
Activity icon

Started a new Conversation Validation Unique To A Belongs To Model

Hi, I am trying to setup some validation but its a bit complicated. I have two models, a Show and Tickets. A show has many tickets and tickets belong to a show. How would I setup a validator that made sure each ticket name of a show was unique. I can't do

'name' => "required|unique:tickets,name",

because two different shows can have the same ticket name. However, for one specific show I only want unique names. My request only has the tickets, so I am not sending the show information along with it.

Jun
18
1 month ago
Activity icon

Replied to Laravel Code Instead Of Link For Verification

@bobbybouwmann Hmm good call. I will try to set this up myself.

Activity icon

Started a new Conversation Laravel Code Instead Of Link For Verification

Hi All, I am trying to switch my site over from verification by email link to a 6 digit code sent to the user. I tried looking for a plugin or tutorial for this but came up short. I was wondering if any of you have found a tool or tutorial that could help me achieve this?

Thanks so much! Chris

Jun
12
1 month ago
Activity icon

Replied to Possible To Add Variable To Emitted Value?

That is what I was looking for!! Thanks so much @tykus

Activity icon

Started a new Conversation Possible To Add Variable To Emitted Value?

Hi, I am emiting a value from my image vue component and I was wondering if there was a way to add a variable to the method it runs. For example

<div v-for="(category, index) in categories">
     <label>
            <image-upload @loaded="onImageEdit"></image-upload>
    </label> 
</div>

// in method:
 onImageEdit(image) {
   //do stuff with image here
}

This works but I would love to be able to pass along the category object as well... like so

<div v-for="(category, index) in categories">
     <label>
            <image-upload @loaded="onImageEdit(category)"></image-upload>
    </label> 
</div>

// in method:
 onImageEdit(image, category) {
   //do stuff with image here
}

This doesn't work but I was wondering if there was a way to do this?

Jun
11
1 month ago
Activity icon

Replied to Laravel Validation Unique Rule Question

Oh I like this method!

Activity icon

Replied to Laravel Validation Unique Rule Question

I actually just thought of a solution that seems to be working

 public function rules()
    {
        if ($this->organizer) {
            return [
                'name' => "required|unique:organizers,name,{$this->organizer->id}",
            ];
        }
        return [
            'name' => "required|unique:organizers,name",
        ];
    }

Is there something wrong with doing it this way?

Activity icon

Replied to Laravel Validation Unique Rule Question

@michaloravec So your solution is to have two different request files? One for Updating and one for storing a new model?

Activity icon

Started a new Conversation Laravel Validation Unique Rule Question

Hi, In my store request rule I have

public function rules()
    {

        return [
            'name' => "required|unique:organizers,name,{$this->organizer->id}",
        ];
    }

This works great when I am updating the organizer but when I am creating a new organizer it fails with the error

Trying to get property 'id' of non-object", exception: "ErrorException",…}

This makes since because I am in the process of creating a new organizer so there wouldn't be an $this->organizer->id. How do I get around this problem?

Jun
08
2 months ago
Activity icon

Started a new Conversation Vue Import Chunks Cache Busting

Hi, I am struggling with Vues chunks. I am importing a large amount of vue templates

Vue.component('favorite', () => import('./pages/layouts/favorite.vue'));
Vue.component('modal', () => import('./pages/layouts/modal.vue'));
Vue.component('tabs', () => import('./pages/layouts/tabs.vue'));
Vue.component('tab', () => import('./pages/layouts/tab.vue'));
etc....

This creates a bunch of js chunks:

0.js
1.js
2.js
3.js
etc...

The issue I am running into is cache busting. I am using laravel mix.version(); but that only adds the hash to my vendor, app and manifest js files. The chunk files don't get hashes and thus I cant bust the cache. Is there a way to deal with this?