kevbrn

kevbrn

Member Since 1 Year Ago

Experience Points 34,870
Experience
Level
Lessons Completed 327
Lessons
Completed
Best Reply Awards 0
Best Answer
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    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 Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

26 Jul
3 months ago

kevbrn left a reply on Return Additional Columns From Polymorphic "pivot" Table?

@staudenmeir yes, it did... I was looking in the wrong place for it.

18 Jul
3 months ago

kevbrn started a new conversation Return Additional Columns From Polymorphic "pivot" Table?

I have a morphToMany()) relationship and I am storing additional data on the intermediate table for the relation... how can I retrieve that data? I tried withPivot('col_name) but that didn't return what I was looking for.

21 Jun
4 months ago

kevbrn left a reply on Extend Auth ResetsPassword Trait?

Ah cool. Like the idea of using the PasswordReset event. Thank you, will give that a shot.

kevbrn started a new conversation Extend Auth ResetsPassword Trait?

I'm looking for the best approach to update an additional field on the user model when someone resets their password without modifying the existing trait that Laravel uses to handle password resets. Basically when a user resets their password, the column 'password_changed_at' would get the current datetime as well.

Thanks!

27 Apr
6 months ago

kevbrn left a reply on Polymorphic Relationship With Where Clause

Realized I was approaching this the wrong way and solved it in the controller.

 $project = Project::where('id', $id)->first();

        $logdata = IssuesLog::where('project_id', $id)       
        ->with(array('actions' =>  function ($query) use($id){
            $query->where('project_id', $id);
        }))
        ->get();

kevbrn started a new conversation Polymorphic Relationship With Where Clause

I need to check for an additional value on a polymorphic relationship so in my model I am doing this

public function project()
    {

        return $this->hasOne(Project::class, 'id', 'project_id');

    }


public function actions()
    {
       
        return $this->morphOne(Actions::class, 'actionable')->where('project_id', '=', ????);

    }

But as specified by the ???? I'm not sure how to pass the project id value. I tried $this->project->id; which returns a project id but it just returns the first project id from the database. I also tried to reference the project() relationship on the model but it doesn't return any data. Not even sure this is possible so any help would be greatly appreciated.

Thanks! Kev

15 Apr
6 months ago

kevbrn left a reply on Child And $refs Not A Function

Key part that I left out. The child component is created multiple times in a v-for so $refs needed to be indexed.

saveItem(index) {
    this.$refs.actionInput[index].saveData();
}

Inspect console and console.log() is your friend :)

kevbrn started a new conversation Child And $refs Not A Function

So a pretty basic setup

Child component in the parent

<actions :item="item" @save="actionData" ref="actionInput"></actions>

The method in the child

methods: {
            saveData() {                
                console.log("fired");
            }
 },

I'm calling the saveData() method from the parent like so.

saveItem() {
                this.$refs.actionInput.saveData();
 },

but I get this error. Uncaught TypeError: this.$refs.actionInput.saveData is not a function

Any ideas?

Thanks!

kevbrn left a reply on Array Of Files Upload To S3

Anyone???

12 Apr
7 months ago

kevbrn left a reply on Access Property Via Relationship In Trait

I figured it out. Its $this->actions->owner_id ... I was discarding that as the possible solution because PHPStorm was telling me that field actions could not be found in HandleActions. Doh!

kevbrn started a new conversation Access Property Via Relationship In Trait

I have a trait ...

trait HandleActions
{

    public function assign($data)
    {

        if($data->action && !$this->actions()->exists())
        {

            $this->store($data);

        }elseif ($this->actions()->exists())
        {

            $this->modify($data);

        }

        return;

    }

    public function actions()
    {

        return $this->morphOne(Actions::class, 'actionable');

    }

    protected function store($data)
    {

        $action = $this->actions()->create([
            'project_id' => $data->project_id,
            'log_id' => $this->getLogID(),
            'log_item_id' => $data->id,
            'created_by' => auth()->user()->id,
            'action' => $data->action,
            'owner_id' => $data->owner_id,
            'due_date' => $data->due_date,
            'comments' => $data->comments
        ]);

        event(new NewActionCreated($action));

    }

    public function modify($data)
    {
       dd($this->actions()->owner_id);

        $this->actions()->update([
            'updated_by' => auth()->user()->id,
            'action' => $data->action,
            'owner_id' => $data->owner_id,
            'due_date' => $data->due_date,
            'comments' => $data->comments
        ]);

        $action = Actions::find($this->actions->id);

        if ($curr_owner <> $action->owner_id) {

            event(new ActionHasBeenReassigned($action));
        }

    }

    protected function getLogID()
    {

        $logid = Log::where('model', get_class($this))->pluck('id');

        return $logid[0];

    }

}

In the modify() method I need to compare the current value of actions()->owner_id to the value that is passed to the trait but I cannot access the property with $this->actions()->owner_id or the method I have on the actions model owner(). I get Undefined Property. Am I going about this the wrong way?

Thanks!

06 Apr
7 months ago

kevbrn started a new conversation Array Of Files Upload To S3

I'm looping over an array of files and wanting to store them in S3 but file() is a method on $request

foreach ($request->$files as $file) {

                $obj->files()->create([
                    'org_id' => session('org_id'),
                    'created_by' => auth()->user()->id,
                    'type' => $file->getMimeType(),
                    'filename' => $file->getClientOriginalName(),
                ]);

                $file->file('files')->storeAs($request->app, $file->filename,'s3');
            }

so I get Call to undefined method Symfony\Component\HttpFoundation\File\UploadedFile::file()

but even if the method were accessible file('files') is no longer valid either, correct?

Is there another method that handles storing an array of files? I looked through Illuminate\Http\UploadedFile but did not see anything.

Thanks!

01 Apr
7 months ago

kevbrn started a new conversation Return In Method Is Not, Returning Response In Render But Does In Console

This method...

methods: {
            getDocs(projid, logid, file) {
                axios.get("/documents/download?project_id=" + projid + "&log_id=" + logid + "&filename=" + file)
                    .then(response => {
                        console.log(response.data);
                        return response.data;
                    });
            },

hits an endpoint that generates a tokenized URL to access a private file in S3. In the template I am iterating over the file reference stored in db and each iteration calls the method.

<div class="row" v-if="documents.length > 0">
    <h3 class="m-b-0 box-title">Current Files:</h3>
        <ul class="common-list">
            <li v-for="(doc, index) in documents" :key="doc.id" class="pointer">
                <a :href="getDocs(doc.project_id, doc.log_id, doc.actual_filename )">
                                        <i class="ti-file"></i> {{ doc.actual_filename }}
                                </a>
                          </li>
                 </ul>
</div>

When I console.log(response.data) I get exactly what I am looking to be returned.

https://www.screencast.com/t/kpLZoobjnbEn

However the return response.data; doesn't return anything, or any error?

Here is the structure of the returned response which is an http response from amazon.

https://www.screencast.com/t/F2BNSAGkm8d

Thanks!

31 Mar
7 months ago

kevbrn left a reply on Migrate Tries To Execute Already Migrated Migrations

Thanks @topvillas and @Thyrosis

@Thyrosis - I'll give that a try. Anytime I need to recreate the app I would just export the db and re-import where needed but I agree keeping those files is ideal. Any ideas why they wouldn't get tracked in the first place?

Thanks!

kevbrn started a new conversation Migrate Tries To Execute Already Migrated Migrations

That's a tongue twister... Occasionally when I run php artisan migrate' it attempts to run migrations that have already been executed thus throwing aBase table or view already exists`. To work around this I usually delete the offending migration but Id prefer to keep them around. How are migrations tracked? Does it just check against the migrations table?

15 Mar
7 months ago

kevbrn left a reply on Merge() Throws Call To Undefined Method

@maslauskast A single instance of Materialso that I can call the relationship methods against it, right? ... but yes, a single item of the Material or Activityinstance. Does that makes sense?

Is the only issue you see the lack of a check for null on $activity?

Thanks so much!

kevbrn left a reply on Merge() Throws Call To Undefined Method

@maslauskast I came to that conclusion as well. Thank you! I changed it to

 foreach ($data->selected_skus as $skus) {

            $material = Material::where('sku', $skus)->get();

            if(!$material->isEmpty()) {

                $product->materials()->syncWithoutDetaching([$material[0]->id => ['qty' => $skus['qty']]]);

            }else{

                $activity = Activity::where('sku', $skus)->get();

                $product->activities()->syncWithoutDetaching([$activity[0]->id => ['qty' => $skus['qty']]]);
            }

        }

$materialshould return a single instance of the collection. I was trying to then add the value of $skus['qty'] to the collection to be inserted.

This works but I'm not sure I like $material[0]

thanks again so very much!

kevbrn left a reply on Merge() Throws Call To Undefined Method

changed to get() But now I get "Call to a member function getKey() on string"

kevbrn left a reply on Merge() Throws Call To Undefined Method

Doh!! Thank you @maslauskast ... I get caught out on that all the time.

kevbrn started a new conversation Merge() Throws Call To Undefined Method

Getting undefined method on merge() and not quite sure why?

foreach ($data->selected_skus as $skus) {

            $material = Material::where('sku', $skus)->first();

            if($material) {               

                $updatedMat = $material->merge([
                    'qty' => $skus['qty'],
                ]);             

                $product->materials()->syncWithoutDetaching([$updatedMat->id => ['qty' => $updatedMat->qty]]);

....

I have verified via dd() that $material is returning the appropriate collection.

works fine on $request and according to the docs merge() works on collections.

https://laravel.com/docs/5.5/collections#method-merge

I'm sure I am just using it incorrectly.

Much appreciated!

KB

10 Mar
8 months ago

kevbrn left a reply on Conditional Vue Component In Blade

@Drfraker thanks, that's pretty much how I have it set up at the moment but seeing as an individual component can (and in the case of my app) make up 100% of the rendered content why keep making blade files? Thinking it would be similar to an SPA maybe?

kevbrn started a new conversation Conditional Vue Component In Blade

What would be the "right" way to accomplish the following.

render a vuejs component in blade depending on the url?

@if(some url string)
    <component-one></component-one>
@elseif(some other url string)
    <component-two></component-two>

....

or with vue-router maybe? or vue dynamic components?

Just looking for the more correct way to go about this.

Thanks, Kevin

18 Feb
8 months ago

kevbrn left a reply on Pass Data To Child Component With`@click`

Hmm ok. That passes the "clicked" data but I can't assign it to any properties.

item is an object.

props: ['item],

data() {
    return{
        item_id: this.item.id
    }
},

Results in item_id being undefined which I assume is because item has no value until the @click but shouldn't it be reactive and assume the value after the click?

kevbrn left a reply on Pass Data To Child Component With`@click`

Thanks @topvillas ... that's how I imagined it in my head... let me give that a try.

kevbrn started a new conversation Pass Data To Child Component With`@click`

Is this possible? I understand you can pass data from a parent component to a child component via props, but what if I want the data in the props to be based on user interaction, @click? Is there a specific method for doing such a thing?

06 Feb
9 months ago

kevbrn left a reply on There Are No Commands Defined In The "command" Namespace.

<?php

namespace App\Console;

use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;

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

    /**
     * Define the application's command schedule.
     *
     * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
     * @return void
     */
    protected function schedule(Schedule $schedule)
    {
         $schedule->command('command:ClearNotificationsTable')
             ->weekly()->mondays()->at('08:00');
    }

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

        require base_path('routes/console.php');
    }
}

kevbrn left a reply on There Are No Commands Defined In The "command" Namespace.

@tykus No they do not. Which is odd.

@mfoote I believe I did it as

php artisan make:command ClearNotificationsTable

They are located in App\Console\Commands

kevbrn left a reply on There Are No Commands Defined In The "command" Namespace.

Ya that's what I am doing.

php artisan command:ClearNotificationsTable

<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;

class ClearNotificationsTable extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'command:ClearNotificationsTable';

kevbrn started a new conversation There Are No Commands Defined In The "command" Namespace.

I have created some commands in my application and I registered them in Console/Commands/Kernel.php

 protected $commands = [
        Commands\ClearNotificationsTable::class,
        Commands\ClearTasksFromNotifications::class,       
    ];

Yes when I try to execute them via artisan php artisan command:ClearNotificationsTable I get the following error.

"There are no commands defined in the "command" namespace."

The command files are all located in Console/Commands

Any ideas?

25 Jan
9 months ago

kevbrn left a reply on Vue Wont Render Table

Was able to resolve by downgrading node.js to v6.11.5

kevbrn started a new conversation Vue Wont Render Table

Ok this is a bizarre one. I've been working on this app for a while and have vue components throughout the app that work perfectly. I get a new computer, move all my utilities and projects to the new computer and get back to work. I'm attempting to add a new vue component so I start building out the vue file and it will not render a simple table if it has a in it... The file doesn't have any JavaScript in it yet, nothing but html and it just will not load. It compiles without errors but as soon as I load it in the browser I get the following.

'Uncaught SyntaxError: Unexpected token )'

the error line from app.js via sources in chrome console

/******/ ]);"td"), <--- this ')' right here
                _vm._v(" "),
                _c("td"),
                _vm._v(" "),
                _c("td"),
                _vm._v(" "),
                _c("td"),
                _vm._v(" "),
                _c("td"),
                _vm._v(" "),
                _c("td"),
                _vm._v(" "),
                _c("td"),
                _vm._v(" "),
                _c("td")
              ])
            ])
          ]
        )
      ])
    ])
  }
]

Here is the vue file itself.


<template>
    <div id="rfi-log-root">
        <div class="table-responsive">
            <table id="myTable"
                   class="tablesaw table-striped table-hover table-bordered table color-table dark-table"
                   data-tablesaw-mode="columntoggle" data-tablesaw-minimap>
                <thead>
                <tr>
                    <th>Unique ID</th>
                    <th>ID</th>
                    <th>Question</th>
                    <th>Requester Name</th>
                    <th>Request Date</th>
                    <th>Response</th>
                    <th>Response Date</th>
                    <th>Documents</th>
                    <th>Unresolved/Closed</th>
                </tr>
                </thead>
                <tfoot>
                <tr>
                    <th>Unique ID</th>
                    <th>ID</th>
                    <th>Question</th>
                    <th>Requester Name</th>
                    <th>Request Date</th>
                    <th>Response</th>
                    <th>Response Date</th>
                    <th>Documents</th>
                    <th>Unresolved/Closed</th>
                </tr>
                </tfoot>
                <tbody>
               <tr>
                   <td></td>
                   <td></td>
                   <td></td>
                   <td></td>
                   <td></td>
                   <td></td>
                   <td></td>
                   <td></td>
                   <td></td>
               </tr>
                </tbody>
            </table>
        </div>
    </div>
</template>


<script>

    export default {
        data() {
            return {

            }
        }
    }

</script>

If I remove the all of the <tr><td> from <tbody> it renders without error. I'm so confused by this one and its roadblocked my progress on all the work I need to get done.

The new computer that I'm developing on is Windows 10. The old one was Windows 8. When I installed PHPStorm on the new computer I exported all of the setting from my old computer and I just have no idea what the deal is here.

Thanks!

16 Jan
9 months ago

kevbrn left a reply on Push Response To Table

ya.. just copied in paste from the console didn't maintain formatting.

kevbrn started a new conversation Push Response To Table

Table is populated from data prop (from Laravel)

<tr v-for="(sku_sub_type, index) in skusubtypes" :key="sku_sub_type.id">
    <td>{{ sku_sub_type.sku_sub_type }}</td>
        <td style="text-align:center">{{ sku_sub_type.sku_type.sku_type }}</td>
        <td style="text-align:center"><i class="icon-pencil"></i></td>
        <td style="text-align:center"><i class="text-danger ti-close"></i></td>
</tr>

User has the ability to add a new item to the database and the new values are push into this skusubtypes

methods: {
            saveItem() {
                let that = this;
                this.loading = true;
                this.form.post('...', this.form)
                    .then(response => {
                        that.loading = false;
                        console.log(response);
                        this.skusubtypes.push(response);
                    })
                //.catch(error => this.errors.record(error.response.errors));
            }
        },

via the console.log I can see that the response contains the correct object,

however this line ...

<td style="text-align:center">{{ sku_sub_type.sku_type.sku_type }}</td>

generates the error "app.js:3423 [Vue warn]: Error in render: TypeError: Cannot read property 'sku_type' of undefined"

this is what is sent back from the axios.post in the response

created_at : "2018-01-16 16:32:29" created_by : 1 id : 2 org_id : 1 sku_sub_type : "Nike Red" sku_type : Object created_at : "2018-01-13 20:00:11" created_by : 1 id : 2 org_id : 1 prod_level : 1 sku_type : "Leather" updated_at : "2018-01-13 20:00:11"

15 Jan
9 months ago

kevbrn left a reply on Map() Not A Function

Found the issue. All my fault. Had not updated the related controller in prod and was getting an object{} instead of an array[]

kevbrn started a new conversation Map() Not A Function

This computed property works perfectly on my local dev server (artisan serve), but when I pushed it to my production server (Ubuntu/Apache) it generates this error

[Vue warn]: Error in render: "TypeError: this.logitems.map is not a function"

computed: {
            daysUntilDue: function () {
                return this.logitems.map(function (logitem) {
                    let b = logitem.plan_complete_date;
                    return moment(b).fromNow();
                });
            },

logitems is data from laravel via a [props]

any ideas?

Im guessing its some difference with the environment but I have no idea what it could be.

Thanks!

10 Jan
10 months ago

kevbrn left a reply on Accessing Dynamic Arrays

Thanks again @kreierson that was the answer. Worked perfectly.

kevbrn left a reply on Accessing Dynamic Arrays

Ah ok. That makes sense. Let me see if I can make that happen. Thanks @kreierson

kevbrn started a new conversation Accessing Dynamic Arrays

A section of my form contains a table of contacts. Clicking a button adds a new row to the table so that more contacts can be added. How do I access the values of these added rows (dynamic array(?) when posting the form.

I am posting the form via a form class like so...

 data() {
            return {
                contact_rows: [
                    {fname: '', lname: '', title: '', phone: '', email: ''}
                ],
                form: new Form({
                    vendor_name: '',
                    vendor_admin: '',
                    primary_phone: '',
                    url: '',
                    nickname: '',
                    address_line1: '',
                    address_line2: '',
                    city: '',
                    state_id: [],
                    zip_code: '',
                    contacts: [
                        { fname: this.contact_rows ??? }
                    ]
                }),
                states: [],
            }
        },

Here is how it looks in vue console.

https://www.screencast.com/t/cVFtclSMs

So in contacts: [] and not quite sure how to set these values from the inputs.

06 Jan
10 months ago

kevbrn left a reply on Access Array Inside Collection?

Thanks @calder12 and @sheldonscott

Much Appreciated!

ended up with

$notification = $user->notifications[0]->data['action_id'];

kevbrn started a new conversation Access Array Inside Collection?

How would I access [data] inside of this collection?

I specifically need to access action_id

{
"id": "BEA9A924-C7C5-4B29-B19B-A4341AABD434",
"type": "App\Notifications\ActionIsPastDue",
"notifiable_id": "73",
"notifiable_type": "App\User",
"data": {
    "action_id": 206,
    "days_late": 23,
    "message": "*REI and VDC DEC teams to...",
    "link": "/logs/actions/my-actions/206"
},
"read_at": null,
"created_at": "2018-01-06 13:14:28.673",
"updated_at": "2018-01-06 13:14:28.673"
}

I have tried...

$notification = $user->notifications->filter(function ($notification) use ($id) {
                return $notification->data->action_id == $id;
            });

and ...


$notification = $user->notifications->data->where('action_id', $id);

but Property [data] does not exist on this collection instance. .Same error when I try it with action_id.

03 Jan
10 months ago

kevbrn left a reply on $emit From Form Class

Ya, I tried that. I think that since the form class is instantiated in a vue instance... eg.

 export default {
        data() {
            return {
                permissions: [],
                form: new Form({
                    name: '',
                    sel_permissions: []
                })
            }
        },

and not a vue instance itself this.$emit is not available.

02 Jan
10 months ago

kevbrn started a new conversation $emit From Form Class

I'm using the form class from https://laracasts.com/series/learn-vue-2-step-by-step/episodes/29 and I was wondering how would you go about $emit an event from it or passing the response back to the calling method?

I tried

 onSuccess(data) {
        $emit('operation-complete', data);

        this.reset();
    }

within the class but the event does not fire. If I put the $emit in the method that calls the this.form.post data is undefined.

Thanks!

24 Dec
10 months ago

kevbrn left a reply on Axios 404 In Different Environment

Removed axios from the equation and replaced with a standard form post/patch and it works perfectly.

kevbrn left a reply on Axios 404 In Different Environment

Ya good point. The app is "fine" essentially. I will look into any axios/IIS related issues.

Thanks @Snapey really appreciate the input. If I find a solution, Ill post back.

kevbrn left a reply on Axios 404 In Different Environment

It appears to be coming from IIS. I have the rewrite for IIS module installed. I will check it out and see if anything seems incorrect there.

kevbrn left a reply on Axios 404 In Different Environment

No I use the artisan serve, server

kevbrn left a reply on Axios 404 In Different Environment

just meaning that when you hit http://domain.com you get the root of the site. Its on IIS and I have the path for the site set to D:\Inetpub\root-folder\sitename\public

is not how it should be configured?