twoarmtom

twoarmtom

Member Since 1 Year Ago

Beamsville

Experience Points 8,460
Experience Level 2

1,540 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 72
Lessons
Completed
Best Reply Awards 1
Best Reply
Awards
  • start-engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-session Created with Sketch.

    School In Session

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

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

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

  • subscriber-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

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

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

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

30 May
1 month ago

twoarmtom left a reply on Reset Password Notification Issue

A strange workaround for this was simply to open up their user information in a form, and re-save it (which updates name and email when the form is submitted), which is easier than deleting them and re-adding them. Then emails go through. It was such strange behavior. Like they're ghosts!

23 May
1 month ago

twoarmtom left a reply on Reset Password Notification Issue

@ANDRESAYEJ - Mailgun is the service, and it works great. It has processed over 1000 emails this month, this is a random occurrence that seems completely remedied when I delete and readd the user. They show up in the application as a user, others with permission can see them there, just none of the emails sent to them make it to the server, so there is no log of them. It's like they're trapped in a queue, but Horizon will show them as processed.

I'm just not sure why it's happening.

twoarmtom started a new conversation Reset Password Notification Issue

I'm not sure if this has happened to anyone, or if someone could shed some light on this.

I've had two users now try to reset their password, and it appears to work, there are no error messages generated on the site. Even Laravel Horizon says the job went through, but it never makes it to the email server.

If I delete the user and re-add them with the same Name and email, they are able to reset their password using the same method as above.

Can anyone think of what might be happening?

27 Apr
2 months ago

twoarmtom left a reply on Comparing Two Arrays To Find A Matching Value (in Random Order)

I just found the answer. pluck returns an object, i needed to add toArray() at the end.

$studentLocations = $student->hospital()->pluck('id')->toArray();

And now it works!

twoarmtom started a new conversation Comparing Two Arrays To Find A Matching Value (in Random Order)

I need to see if any value in one array exists in another array, and the numbers are in random order. I have found solutions that don't seem to work when the order of the values is not in exactly the same order.

I have tried array_intersect, but this does not work if the number I'm looking for is not in the same order.

$array1 = [1,2];
$array2 = [2,3];

$result = array_intersect($array1, $array2);

$result is returning false, but I want it to realize that 2 exists in both arrays and return true.

I imagine this has a simple solution, but can't find anything that works.

Here is the full code (using PHP, Laravel):

$student = User::find($id);
$studentLocations = $student->hospital()->pluck('id');
$preceptorLocations = Auth::user()->hospital()->pluck('id');

$result = array_intersect($studentLocations, $preceptorLocations);

If if return the results of either $arrays individually:

[2,3] // studentLocations
[1,2] // preceptorLocations

But, with array_intersect code above I get:

"array_intersect(): Argument #1 is not an array"

If I change to array($student->hospital()->pluck('id')) for example, it doesn't get an error, doesn't return true, and when I return just the results they are like this:

[[2]]

Does anyone know what is happening?

21 Apr
2 months ago

twoarmtom left a reply on Inserting The Information For A Range Of Dates

@ASHRAAM - Thank you, that did the trick!

18 Apr
3 months ago

twoarmtom started a new conversation Inserting The Information For A Range Of Dates

I'm trying to find examples of properly looping through a range of dates to insert information.

Currently, I am creating a schedule row with the user, location etc., and a single date in a form using:

Schedule::create($request->all());

But I would like to add start and end date and create identical row information (user, location, etc.), looping through each date in the range, and stopping after the end date is inserted. Assuming two dates would be something like:

$request->start_date
$request->end_date

I found some examples with messy PHP, but I'm assuming there is a more 'eloquent' way to do this. Any help would be greatly appreciated.

Thank you.

06 Apr
3 months ago

twoarmtom left a reply on Dealing With URLs And Forge Load Balancing

@LOACH - I understand now, thank you for the clarification.

twoarmtom left a reply on Dealing With URLs And Forge Load Balancing

@LOACH - Why not just scale up a server? And why do all demos use examples with "app-1" and "app-2". Very confusing for those of learning about this stuff haha.

twoarmtom left a reply on Dealing With URLs And Forge Load Balancing

@LOACH - Yes, I wasn't clear on whether you can balance traffic between different applications on different servers, which is what it appeared to be telling me I could do.

twoarmtom started a new conversation Dealing With URLs And Forge Load Balancing

I'm watching tutorial videos and looking online, and I just want to make sure I understand this correctly before I do it as I can't find a clear example.

I currently have 3 servers each with their own app and custom domain pointed to them. I was considering to add a load balancer, and I was wondering if I need to now redirect all DNS for the domains to the load balancer IP (instead of the current servers), and it will just sort it out provided they are all connected?

10 Feb
5 months 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
6 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
6 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
6 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
6 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
6 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
1 year 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
1 year 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
1 year 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
1 year 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');