twoarmtom

twoarmtom

Member Since 1 Year Ago

Beamsville

Experience Points 7,390
Experience Level 2

2,610 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 64
Lessons
Completed
Best Reply Awards 1
Best Reply
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.

10 Feb
1 month ago

twoarmtom left a reply on Value "Undefined" With Vue Form Submit

@BOBBYBOUWMANN - I get a vue warning in the console that rows is not defined and the form won't show when clicked now. Here is the full table code (I'm using bootstrap-vue, except for the form, but the same happens when I use bootstrap-vue's form code.) Rows from the data function are rendered in the table automatically, but you can manipulate a row by using template with slot="" and slot-scope="row" to work with it.

<template>

    <b-container fluid>
        <b-table show-empty empty-text="Please wait while the competencies load." striped responsive stacked="md"
                 :items="items" 
                 :fields="fields" 
                 >
            <template slot="num_skills_required" slot-scope="row">
                <span v-if="show">{{ row.item.num_skills_required }}</span>
            <div v-for="(row, index) in rows">
                <form v-if="!show" @submit.prevent="editNumber(index)">
                    <div class="form-group">
                        <input type="number" name="num_skills_required" v-model="row.item.num_skills_required" class="form-control">
                    </div>
                    <div class="form-group">
                        <button type="submit" class="btn btn-primary">Confirm</button>
                    </div>
                </form>
            </div>
            <b-button v-if="show" @click="show = !show" variant="warning" size="sm"><span class="icon icon-pencil"></span></b-button>
            </template>
</b-table>
</b-container>

</template>

<script>
    const items = [];
    export default {
        props: ['competencies'],
        data() {
            return {
                items: this.competencies,
                fields: [{
                        key: "standard",
                        label: "Standard",
                    },
                    {
                        key: "num_skills_required",
                        label: "Required"
                    }
                ],
            show: true,
            };
        },
        methods: {
            editNumber(rowIndex) {
                let row = rows[rowIndex];

                alert('Number is ' + row.item.num_skills_required);
            }
        },
    };
</script>

twoarmtom left a reply on Value "Undefined" With Vue Form Submit

@BOBBYBOUWMANN - I tried that and get console errors that 'item' is not defined (items is passed to the table), your are correct that there are multiple rows. How would I access the num_skills_required column with the row id?

Thank you for your help.

twoarmtom started a new conversation Value "Undefined" With Vue POST

I have spent hours trying to figure out why my data can't pass into a function. I'm trying to edit a row in a table. Here is a form I have:

<form @submit.prevent="editNumber()">
                    <div class="form-group">
                        <input type="number" name="num_skills_required" v-model="row.item.num_skills_required" class="form-control">
                    </div>
                    <div class="form-group">
                        <button type="submit" class="btn btn-primary">Confirm</button>
                    </div>
</form>
'''

Here is the basic function just to see if I can send the right data to the function, and I get Number is "undefined.

methods: { editNumber() { alert('Number is ' + this.num_skills_required);

        }
    },
17 Jan
2 months ago

twoarmtom left a reply on Relationship Won't Show In User Resource

@MANELGAVALDA - I had the singular in my regular User model.......glad it was something simple, disappointed I missed it!

Thanks!

16 Jan
2 months ago

twoarmtom started a new conversation Relationship Won't Show In User Resource

I'm having trouble with getting a relationship to work in Nova,

My Evaluation Resources shows the User no problem with the following:

BelongsTo::make('User')

But my Evaluation resource with this:

HasMany::make('Evaluations'),

Gets the error:

Method Illuminate\Database\Query\Builder::evaluations does not exist

I know to use the plural form of the relationship, and it gets different errors when I use sinuglar.

Any ideas?

11 Jan
2 months ago

twoarmtom left a reply on Multiple Variables Returned With Axios In Vue

@DRFRAKER - Hi, @drfraker I revisited this again motivated by the fact that your code was exactly what I needed, but I'm having issues getting it into my vue component...sort of. I can get it to display, but it breaks the pagination feature with bootstrap-vue tables....likely I'm doing something wrong.

Here is how I handled it. Here is what returns:

.then((res) => {
        this.unassessed = res.data.unassessed
        this.assessed = res.data.assessed
        this.completed = res.data.completed
      })

Then to get it into my table which has :item, it works if I put :item="objectname" for each table (there are three separate tables on the page). BUT when I do it like this, it breaks pagination (so I've taken out the pagination feature, but it makes me feel like I'm doing something wrong. This is how I'm making the returned objects available, probably something wrong here but I can't find a good reference anywhere.


<script>
const items = [];
export default {
  props: ["id"],
  data() {
    return {
      unassessed: items,
      assessed: items,
      completed: items,
      fields: [ ...etc.

Any tips or feedback would be great. Thanks so much!

08 Jan
2 months ago

twoarmtom left a reply on Multiple Variables Returned With Axios In Vue

What you suggested was perfect, I'm able to verify the correct data is coming back, I just can't seem to get it to show up in my component. I think I'm getting in over my head at the moment. Was trying to include vue components into more of Laravel pages, but in more complicated situations than I'm used to.

I was passing an id to the component via props, using it to make an axios call, but can't seem to reference the returned data properly in the view.

Thanks for your help.

twoarmtom left a reply on Multiple Variables Returned With Axios In Vue

Awesomen, thank you! Will test this out in the morning. I should have posted this message before exhausting myself trying to find other work arounds!

Appreciate it.

07 Jan
2 months ago

twoarmtom left a reply on Multiple Variables Returned With Axios In Vue

Thanks!, So current I have this.items = response.data.

Would I do something like this.object1 = response.object1 etc?

twoarmtom started a new conversation Multiple Variables Returned With Axios In Vue

Hi everyone, I'm still pretty new in using Vue at this time, I can't seem to find any examples of this, but is it possible to return a response with multiple variables from a controller with an axios.get request? I'm currently using it to return one object array, but can I do two different ones?

Similar to the compact('objectarray1', 'objectarray2') performed in the Controller for returning multiple objects to a view.

16 Jul
8 months ago

twoarmtom left a reply on Accessing The Users Data From Vue Component With API Routes

@bulresearch I just removed the api.php resource routes and made regular web routes to the controller and I was able to pull in the data with axios. I think when I tried that earlier I was logged in as a user without any pivot table data so there was no data. I tried it again and it worked (with proper user data).

Route (protected by middleware for the user role)

Route::get('/attempts', '[email protected]');

This works now

public function index()
    {
        //
        $user = Auth::user();
        return response($user->competency()->orderBy('category')->get());
    }
mounted() {
        axios.get('/attempts')
        .then(response => this.comps = response.data);
    }

Thanks for your replies, I appreciate it, motivated me to keep at it! I'll hold off on Passport for now and see if this continues to work for what I need it for,

twoarmtom left a reply on Accessing The Users Data From Vue Component With API Routes

@burlresearch The route is in the api.php

Route::resource('/attempts', 'AttemptsController');

Vue component file

<script>
export default {
    data() {
        return {
            comps: []
        }
    },
    mounted() {
        axios.get('/api/attempts')
        .then(response => this.comps = response.data);
    }
}
</script>

Everything works if I load data not associated with the user, but when I try to load data affiliated to the user I get > "Call to a member function competencies() on null"

15 Jul
8 months ago

twoarmtom left a reply on Laravel 5.4 Messaging Logout

You should be able to create the session before the redirect.

public function authenticated(Request $request, $user)
{

    if ($user->confirmed != 1) {

      Auth::logout($request);
    session()->flash('logout', "You successfully logged out");

       return redirect('/login');

    }
    else{

        $request->session()->flash('status', 'You are successful log in!');

    }
}

And make sure you have the flash message displayed on your login page after redirection by including it somewhere on the page

@if ($flash = session('logout'))
            <strong>{{ $flash }}</strong>
@endif 

Wrap it in an alert box and fade it out if you want it to look nice (like bootstrap alert component).

twoarmtom left a reply on Accessing The Users Data From Vue Component With API Routes

@burlresearch The controller is part of an axio api request, and it can't seem to utilize the current authenticated user. I'm trying access a list of competencies associated with the logged in user. I want them to be able to interact with them using ajax (axios) requests.

''' public function index() { // return response(Auth::user()->competencies()->orderBy('category')->get()); } '''

Fails because user is null.

twoarmtom started a new conversation Accessing The Users Data From Vue Component With API Routes

I would like to have a users stored information accessible in a Vue component. However, when I use Auth::user() in the controller associated with the API resource (using a axios), it returns null. After extensive reading it seems like I may need to use Passport in order to use the current user in a controller function when the controller is part of an API.

Before I start going down that road I’m wondering if anyone knows another way to pass the current logged in user into the a API controller to retrieve their data? Or do I have to use Passport?

09 Jul
8 months ago

twoarmtom left a reply on Counting A Value Only If It Appears More Than Once In A Table.

I found a way to do it by adding another column to the table that is set to true if the evaluation for the student and competency is given the value of 3 a second time.

In my controller, after evaluation is created:

if (SubmittedCompetency::where('competency_id', $evaluation->competency_id)->where('student_id', $evaluation->student_id)->where('evaluation', 3)->count() == 2) 
            {
                $evaluation->update([
                    'isEtP' => true
                ]);
            }

Then I run the following query in the view (because there is more than one student on in the page, and I had to do this for each student) the count I needed:

$completed_competencies = DB::table('submitted_competencies')
                                ->where('student_id', $student->id)
                                ->where('isEtP', 1)
                                ->count();

Blade:

{{ $completed_competencies }} Complete

08 Jul
8 months ago

twoarmtom left a reply on Counting A Value Only If It Appears More Than Once In A Table.

@Danchez close, but I want to know when evaluation >2 for the distinct competency happens at least twice in the table. This example counts it even if it only appears once in the table.

twoarmtom left a reply on Counting A Value Only If It Appears More Than Once In A Table.

@mhmd_daka Unfortunately, it does not work. And it ignore a few things. 1) I need it to be only competencies belong to a certain students. 2) I only want it to count the row belonging to the student and specific competency if the evaluation score was 3 more than once. In other words, the student received a perfect score (3) at least twice before it shows up on a report (which I'm displaying as a numeric count).

I tried adjusting the code to consider these things, and it counts all distinct competencies with evaluation of 3 belonging to a student, but it still counts it even it only happened once.

$completed_competencies = DB::table('submitted_competencies')
                                ->where('student_id', $student->id)
                                ->where('evaluation', 3)
                                ->groupBy('competency_id')
                                ->havingRaw('Count(competency_id) > 1')
                                ->count('competency_id');

With "competency_id", it seems to at least group the distinct competencies that occur more than once. If I use "evaluation" above for groupBy and havingRaw, it just does a total count where evaluations are 3, even if its the same competency multiple times.

twoarmtom left a reply on Counting A Value Only If It Appears More Than Once In A Table.

@Danchez The query works for count how many evaluations has a value of 3 that belong to the student, but I only want the count if they have received the score of 3 more than once.

twoarmtom started a new conversation Counting A Value Only If It Appears More Than Once In A Table.

I'm having trouble getting a count based on a special condition.

Basically, a "completed competency" is one that receives an evaluation of 3 at least two times. The following code works for counting how many distinct competencies have an evaluation of 3, but I want it to only count them if the distinct competency_id has an evaluation of 3 at least twice in the database for the specified student. Any suggestions?

$completed_competencies = DB::table('submitted_competencies')
                                ->where('student_id', 202)
                                ->where('evaluation', 3) // I want this to happen twice for the same competency_id before it is counted.
                                ->distinct('competency_id')
                                ->count('competency_id');