kevbrn

Experience

26,840

0 Best Reply Awards

  • Member Since 1 Year Ago
  • 253 Lessons Completed
  • 4 Favorites

18th February, 2018

kevbrn left a reply on Pass Data To Child Component With`@click` • 2 days ago

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` • 2 days ago

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` • 2 days ago

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?

6th February, 2018

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

<?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. • 2 weeks ago

@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. • 2 weeks ago

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. • 2 weeks ago

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?

25th January, 2018

kevbrn left a reply on Vue Wont Render Table • 3 weeks ago

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

kevbrn started a new conversation Vue Wont Render Table • 3 weeks ago

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!

16th January, 2018

kevbrn left a reply on Push Response To Table • 1 month ago

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

kevbrn started a new conversation Push Response To Table • 1 month ago

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"

15th January, 2018

kevbrn left a reply on Map() Not A Function • 1 month ago

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 • 1 month ago

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!

10th January, 2018

kevbrn left a reply on Accessing Dynamic Arrays • 1 month ago

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

kevbrn left a reply on Accessing Dynamic Arrays • 1 month ago

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

kevbrn started a new conversation Accessing Dynamic Arrays • 1 month ago

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.

6th January, 2018

kevbrn left a reply on Access Array Inside Collection? • 1 month ago

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? • 1 month ago

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.

3rd January, 2018

kevbrn left a reply on $emit From Form Class • 1 month ago

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.

2nd January, 2018

kevbrn started a new conversation $emit From Form Class • 1 month ago

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!

24th December, 2017

kevbrn left a reply on Axios 404 In Different Environment • 1 month ago

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 • 1 month ago

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 • 1 month ago

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 • 1 month ago

No I use the artisan serve, server

kevbrn left a reply on Axios 404 In Different Environment • 1 month ago

Ah, gotcha

kevbrn left a reply on Axios 404 In Different Environment • 1 month ago

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?

kevbrn left a reply on Axios 404 In Different Environment • 1 month ago

The get returns 200 OK. The patch returns 404. Really at a loss on this one. Think I will just have to use a traditional form. Very odd as I have another app on the same server that uses axios exclusively for all form interaction and works without issue.

kevbrn left a reply on Axios 404 In Different Environment • 1 month ago

I have setup a dedicated controller with 2 methods, index and update. Will report back what I find

kevbrn left a reply on Axios 404 In Different Environment • 1 month ago

it responds as root and no need to put index.php, public is the entry point

kevbrn left a reply on Axios 404 In Different Environment • 1 month ago

Thanks guys. I changed the path to /logs/set-review-date/'+ id and still get a 404

I cleared caches... config:cache and cache:clear and even route:clear but still get a 404.

kevbrn started a new conversation Axios 404 In Different Environment • 1 month ago

I have a function in my app that sends a patch request via axios that works perfectly on my local dev machine. However when I promoted the changes to my remote UAT server, that very same patch requests gives me a 404. I verified thatthe path is in the routes file and that the correct endpoint is on the controller ... all the same code that is on my local machine. Is there something environmental that would prevent this from working?

On the UAT server, I changed the patch to get and tested it and I got a response as expected (no 404) ... its as if the routes file cant understand the patch so I changed it to post still get a 404. I have other patch requests in the app that are handled via traditional forms that work without issue. Really stumped on this one.

Routes file.

Route::patch('/logs/cost optimization/set-review-date/{id}', '[email protected]');

Controller.

  public function setReviewDate(Request $request)
    {

        CostOptimizationLog::where('id', $request['id'])->update([
            'ready_for_review' => $request['reviewDate']
        ]);

        return 'Review Date has been updated';

    }

Method from vue component.

 update(id){
                let that = this
                axios.patch('/logs/cost optimization/set-review-date/'+ id, this.input)
                    .then(function (response) {
                        //console.log(response);
                        that.editing = false;
                    }).catch(function (error){
                        console.log(error);
                });
            }

Again all of this works great locally and all I did was push the changes to a remote host.

Thanks in advance for the help!

19th December, 2017

kevbrn left a reply on Reload Parent Data On Child Save/update • 2 months ago

Thanks @wilk_randall

kevbrn left a reply on Reload Parent Data On Child Save/update • 2 months ago

Thanks @wilk_randall ... what does that typically look like?

kevbrn started a new conversation Reload Parent Data On Child Save/update • 2 months ago

I'm loading a parent component with user data from the controller. The parent component has a child component for adding a new user, everything works as expected and now I want the parent component's data to re-actively show the newly added user once the post request to axios is complete. I assume this will be achieved with an $emit that triggers a method on the parent to "refresh" the axios.get ? Would this be the right approach?

18th December, 2017

kevbrn left a reply on MorphsTo/morphOne Does Not Save The _id Column • 2 months ago

Bump. Still haven't got this sorted. Anyone?

15th December, 2017

kevbrn left a reply on MorphsTo/morphOne Does Not Save The _id Column • 2 months ago

Thanks @bobbybouwmann I implemented that but it throws ...

Argument 1 passed to Illuminate\Database\Eloquent\Relations\HasOneOrMany::create() must be of the type array, object given

14th December, 2017

kevbrn started a new conversation MorphsTo/morphOne Does Not Save The _id Column • 2 months ago

I have a table 'actions' that needs a relationship to several other 'log' tables. I setup a 'morphOne' relationship between the individual 'log' tables and the 'actions' table. Everything works as expected with the exception of when I save a new record in the 'actions' table, it save the related 'log' model type in 'action_type' but not the 'action_id'?

models:

class Actions extends Model
{
    public function action()
        {

            return $this->morphTo('action'); //more attributes???

    }
}

class AssumptionVerification extends Model
{
    public function actions()
    {

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

    }
}

On the 'action' controller

    public function store(Log1 $log1, Request $request)
    {
        $assumptionVerification->action($request);

        return back();

    }

On the 'log1' model

 public function action($request)
    {

        $this->actions()->create([
            'owner_id' => $request['owner_id'],
            'project_id' => $request['project_id'],
            'log_id' => $request['log_id'],
            'log_item_id' => $request['log_item_id'],
            'action' => $request['action'],
            'due_date' => $request['due_date'],
            'comments' => $request['comments'],
            'created_by' => $request['created_by']
        ]);

    }

Like I said, everything works just as expected except 'action_id' remains null after creating a new 'action' record but 'action_type' gets the appropriate value.

If I manually add the correct value for 'action_id' in the 'actions' table, I can retrieve the data via the relationship.

help much appreciated!

Thanks, Kevin

12th December, 2017

kevbrn left a reply on Vue Template Not Rendering, No Errors • 2 months ago

That did it! @bobbybouwmann thank you so much! I owe you big time :)

I did update this.items.splice(index, 1); to that.items.splice(index, 1); and once I did it worked as desired.

Huge thanks!

11th December, 2017

kevbrn left a reply on Vue Template Not Rendering, No Errors • 2 months ago

So, after much trial an error this works... sort of.

methods: {
            del(index) {
                swal({
                    title: "Are you sure?",
                    type: "warning",
                    showCancelButton: true,
                    confirmButtonColor: "#DD6B55",
                    confirmButtonText: "Yes, delete it!",
                    closeOnConfirm: false
                }, function () {
                    swal({
                        title: "Deleted!",
                        type: "success"
                    }, function () {

                        //axios.delete('/admin/permissions/' + id);

                    });
                });
                this.items.splice(index, 1);
            }
        }

It was all in where I referred to this and the correct method apparently is splice(). While this does remove the item of the data its fires in the wrong place. Was hoping to have it fire after the axios delete, but at that point in the function this."anything" is undefined. May have to resort to a less complex confirmation method.

kevbrn left a reply on Vue Template Not Rendering, No Errors • 2 months ago

@bobbybouwmann I've tried that one and all I get is Uncaught TypeError: Cannot read property 'slice' of undefined :(

10th December, 2017

kevbrn left a reply on Vue Template Not Rendering, No Errors • 2 months ago

@bobbybouwmann man you're a lifesaver, that works. However I had to pull the entire <table> into the vue template which I thought was odd. Before I did that it would render the <tr> outside of the table entirely.

anyway, that got me up and running... directly into my next brick wall. In this table I have a @click so that I can delete a row and its data.

like so...

<td style="text-align: center"><a href="#" id="sa-warning"><i
                        class="ti-close text-danger" @click="destroy(permission.id, index)"></i></a></td>

then a destroy method...

 methods: {
            destroy(id, index) {
                swal({
                    title: "Are you sure?",
                    type: "warning",
                    showCancelButton: true,
                    confirmButtonColor: "#DD6B55",
                    confirmButtonText: "Yes, delete it!",
                    closeOnConfirm: false
                }, function () {
                    swal({
                        title: "Deleted!",
                        type: "success"
                    }, function () {
                        //axios.delete('/admin/permissions/' + id);

                        alert(id + '' + index)

                        items.slice(index, 1)

                    });
                });
            }
        }

the alert() returns the correct id, and index but how can I now remove that item from the data so that it is no longer visible on the page without doing a post back?

Again thank you tremendously!

kevbrn started a new conversation Vue Template Not Rendering, No Errors • 2 months ago

As an inline template vue was rendering the expected table on the page. I've now moved it into its own component and nothing is being displayed in the browser. I can see the data in the vue console and there are no errors in chrome console but alas no content...

in view

    <table id="myTable" class="table table-striped">
                            <thead>
                            <tr>
                                <th>Name</th>
                                <th>Created At</th>
                                <th>Created By</th>
                                <th style="text-align: center">Edit</th>
                                <th style="text-align: center">Delete</th>
                            </tr>
                            </thead>
                            <permissions :data="{{ $permissions }}"></permissions>
       </table>

permissions.vue file ...

<template>
    <tbody>
        <tr v-for="permission in items">
            <td>{{ items.name }}</td>
        </tr>
    </tbody>
</template>

<script>
    export default {
        props: ['data'],

        data() {
            return {
                items: this.data
            }
        }
    }
</script>

app.js


Vue.component('flash', require('./components/Flash.vue'));
Vue.component('user', require('./components/User.vue'));
Vue.component('permissions', require('./components/Permissions.vue'));

const app = new Vue({
    el: '#app'
});

Again no browser errors and no compile errors.

Assistance always appreciated!

Kevin

9th December, 2017

kevbrn left a reply on Undefined In V-for • 2 months ago

@robrogers3 Your response got me to the right place. I needed to not only pass the id in the method but also have the method accept the id. This works...

  methods: {
            destroy(id) {
              //axios.delete('/permissions/' + this.attributes.id);
                alert(id)
            }
        }
    }

Thank you so very much! Kevin

kevbrn left a reply on Undefined In V-for • 2 months ago

@robrogers3 you mean like so...

@click="destroy(attribute.id) ? I have tried that and I get the same error.

kevbrn started a new conversation Undefined In V-for • 2 months ago

I am following along in this video (https://laracasts.com/series/lets-build-a-forum-with-laravel/episodes/33?autoplay=true)

I am trying to delete an item from the database using the example from the video. I have my app setup pretty much the same except I'm rendering data in a v-for loop. When I click to call the "destroy" method, all I get is id is undefined...

in my view...

<permission :attributes="{{ $permissions }}" inline-template>
                            <table id="myTable" class="table table-striped">
                                <thead>
                                <tr>
                                    <th>Name</th>
                                    <th>Created At</th>
                                    <th>Created By</th>
                                    <th style="text-align: center">Edit</th>
                                    <th style="text-align: center">Delete</th>
                                </tr>
                                </thead>
                                <tbody>

                                    <tr v-for="(attribute in attributes" >
                                        <td>@{{ attribute.name }}</td>
                                        <td>@{{ attribute.created_at }}</td>
                                        <td>@{{ attribute.created_by }}</td>
                                        <td style="text-align: center" v-if="attribute.id == 1">
                                            <i class="ti-lock"></i>
                                        </td>
                                        <td style="text-align: center" v-else>
                                            <a><i class="icon-pencil"></i></a>
                                        </td>
                                        <td style="text-align: center" v-if="attribute.id == 1">
                                            <i class="ti-lock"></i>
                                        </td>
                                        <td  style="text-align: center" v-else><a href="#" @click="destroy"><i
                                                        class="ti-close text-danger"></i></a></td>
                                        </td>
                                    </tr>

                                </tbody>
                            </table>
                        </permission>

In my VUE component...

<script>
    export default {
        props: ['attributes'],

        data() {
            return {
                editing: false,
                body: this.attributes.body
            };
        },

        methods: {
            destroy() {
              //axios.delete('/permissions/' + this.attributes.id);
                alert(this.attributes.id)
            }
        }
    }

</script>

And all that is in the alert() is undefined. Any help is greatly appreciated.

Thanks, Kevin

22nd November, 2017

kevbrn left a reply on Access Global Scope Relationship? • 2 months ago

@snapey That works! So it is 'OK' to have that in my view or is there a more blade friendly approach?

Thank you so much!

kevbrn left a reply on Access Global Scope Relationship? • 2 months ago

Thanks @bobbybouwmann

Cant seem to get this to do what I need it to. Will have to come up with another approach.

kevbrn left a reply on Access Global Scope Relationship? • 2 months ago

I noticed that user_discipline is an array and not a collection? Is that right?

{  
   "id":210,
   "first_name":"Adam",
   "last_name":"XXXXX",
   "company_name":"XXXX",
   "app_role_id":"1",
   "project_id":null,
   "discipline_id":"22",
   "project_role_id":"76",
   "contact_id":null,
   "active_phases":null,
   "status":"1",
   "verified":"0",
   "email":"XXXXX",
   "cell_phone":"XXXX",
   "user_profile_pic":"nopic.png",
   "created_at":"2017-11-11 22:08:53.000",
   "updated_at":"2017-11-11 22:08:53.000",
   "is_admin":"0",
   "is_contact":"0",
   "pivot":{  
      "project_id":"1",
      "user_id":"210"
   },
   "user_discipline":[  
      {  
         "id":22,
         "name":"discipline_id",
         "value":"06. Structural",
         "created_at":null,
         "updated_at":null
      }
   ]
}

21st November, 2017

kevbrn left a reply on Access Global Scope Relationship? • 2 months ago

@Snapey ya that too

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.