themccallister

themccallister

Member Since 5 Years Ago

Chesapeake, VA

Lead Developer/Team Lead at Trader Interactive

Experience Points 45,015
Experience Level 10

4,985 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 585
Lessons
Completed
Best Reply Awards 0
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.

11 May
2 months ago

themccallister left a reply on How To Work On Different Version Of Laravel?

I know this is late, but Laravel Shift would perform a lot of this for you. I haven’t used it and understand your approach because it makes perfect sense to me!

07 May
2 months ago

themccallister left a reply on How To Work On Different Version Of Laravel?

@pilat I think your approach is the right way to go. However, there are always alternatives.

One alternative would be to start a new repository and move the models, controllers and etc over one at a time but it sounds like you are already in the process of upgrading.

To make things easier, it might be helpful to place a bash script in your directory to install composer and node dependencies in one command, something like deps when you are switching back and forth.

12 Dec
7 months ago

themccallister left a reply on Configs For Nova Custom Tools

I should clarify my previous statement, you should only use env variables through a config so you can leverage config caching.

11 Nov
8 months ago

themccallister left a reply on Configs For Nova Custom Tools

Nova tools should definitely not be using environment variables, curious to see what you find out.

themccallister left a reply on Nova Repeatable Fields

There is no official first party support, but if you look on novapackages.com there is a field for one: https://novapackages.com/packages/fourstacks/nova-repeatable-fields

10 Dec
2 years ago

themccallister left a reply on Queue A Job From A Command?

This was an operator error, my queue was configured but not running locally.

Problem solved :)

06 Dec
2 years ago

themccallister started a new conversation Queue A Job From A Command?

I have a command, named ImportMonthlyDataCommand. Inside that command I am attempting to queue multiple jobs.

Here is the command...

$this->info("Queuing import for ${niceMonth}, ${year}");

$data = Data::all();

foreach ($data as $data) {
    dispatch(new ImportMonthlyDataFromApi($data, $month, $year));
}

$this->info("Import has been queued for ${niceMonth}, ${year}");

Inside of the job, I am making a request to an API with certain parameters and using Guzzle.

However, each time I dispatch the job, the command waits until the job completes before the last $this->info displays... Is this an issue with the command or should I make a synchronous request with Guzzle?

27 Apr
3 years ago

themccallister started a new conversation Merging Two Collections Based On Matching Key Values

I have two collections, I'll keep the naming simple here:

$leadTableCollection contains arrays of items like this:

Illuminate\Support\Collection#1
(
    [*:items] => array
    (
        0 => array
        (
            '_new_lead_value' => 'unique-string'
                // other misc key value pairs
        1 => array
        (
            '_new_lead_value' => 'unique-string'
            // other misc key value pairs
        2 => array
        (
            '_new_lead_value' => 'unique-string'
            // other misc key value pairs
        3 => array
        (
            '_new_lead_value' => 'unique-string'
            // other misc key value pairs
        )
    )
)

The other collection $leadsCollection looks like this:

Illuminate\Support\Collection#1
(
    [*:items] => array
    (
        0 => array
        (
            'leadid' => 'unique-string'
            // other misc key value pairs
        1 => array
        (
            'leadid' => 'unique-string'
            // other misc key value pairs
        2 => array
        (
            'leadid' => 'unique-string'
            // other misc key value pairs
        3 => array
        (
            'leadid' => 'unique-string'
            // other misc key value pairs
        )
    )
)

What I'm trying to accomplish is to create a new key, named lead_details, on the first collection ($leadTableCollection) where the two collections are intersecting...

The end result would look like this:

Illuminate\Support\Collection#1
(
    [*:items] => array
    (
        0 => array
        (
            '_new_lead_value' => 'unique-string'
            'lead_details'  => array
            (
                'leadid' => 'the-leads-unique-id',
                'full_name' => 'Example Full Name'
            )    
            // other misc key value pairs
        1 => array
        (
            '_new_lead_value' => 'unique-string'
            'lead_details'  => array
            (
                'leadid' => 'the-leads-unique-id',
                'full_name' => 'Example Full Name'
            )    
            // other misc key value pairs
        2 => array
        (
            '_new_lead_value' => 'unique-string'
            'lead_details'  => array
            (
                'leadid' => 'the-leads-unique-id',
                'full_name' => 'Example Full Name'
            )    
            // other misc key value pairs
        3 => array
        (
            '_new_lead_value' => 'unique-string'
            'lead_details'  => array
            (
                'leadid' => 'the-leads-unique-id',
                'full_name' => 'Example Full Name'
            )    
            // other misc key value pairs
        )
    )
)

This way I can combine the response from the API into one multi-dimensional array to display on the front end.

11 Apr
3 years ago

themccallister started a new conversation Artisan Make:test Command In Lumen

I know I could probably write my own, but I would really like to move the artisan command "make:test" into my Lumen 5.1 API project.

Where can I find this in Laravels code so I can copy this and make this possible for my Lumen project?

31 Dec
3 years ago

themccallister left a reply on Querying A Relationship On The Model Itself...

@JoeDawson that is correct, sorry it if was not clear.

themccallister left a reply on Querying A Relationship On The Model Itself...

@premsaurav wherePivot would return the pivot table of project_user. That table does not store the attribute is_client.

@AkiyamaSmart thanks but I would rather find a proper way to solve this, also I'm not on the clock :)

themccallister started a new conversation Querying A Relationship On The Model Itself...

Alright, this is one is starting to irritate me so I had to ask here.

I have a model step, lets say a Project. This project has a belongs to many relationship of users like so:

public function users()
{
    return $this->belongsToMany('App\User')->withTimestamps();
}

On the user model, I have the attribute is_client as a boolean. When I am working with a project, I want to select all of the users that is_client is true. How can I add that to my model as a helper method?

22 Mar
4 years ago

themccallister left a reply on CSRF Issue When Trying To Upload A Video?

Ok, so I am going to post my full code here. Moved the code into a whole new Laravel 5 installation and I am still getting the same issue.

HTML Form:

{!! Form::open(['route' => ['projects_videos_update', $project->id], 'method' => 'post', 'files' => true]) !!}
        <h2>Add a Video</h2>
        <p>Select your video.</p>
        <div class="field file">
            <span class="label offleft">
                <label for="videoField">Video</label>
            </span>
            {!! Form::file('video', ['class' => 'video', 'id' => 'videoField']) !!}
        </div> <!-- /.field -->
        <div class="field select">
            <span class="label">
                <label for="videoCategory">Category</label>
            </span>

                    <span class="selectWrap">
                        <select name="category" id="videoCategory">
                            @foreach($categories as $category)
                                <option value="{{ $category->id }}">{{ $category->name }}</option>
                            @endforeach
                        </select>
                    </span>
        </div> <!-- /.field -->
        <p>
            <button type="submit" class="button">Add Video</button>
            <button type="button" class="button danger cancel">Cancel</button>
        </p>
        {!! Form::close() !!}

Routes.php

Route::get('projects/{id}/videos', ['as' => 'projects_videos', 'uses' => 'VideoController@show']);
Route::post('projects/{id}/videos', ['as' => 'projects_videos_update', 'uses' => 'VideoController@upload']);

And finally the controller:

public function upload(Request $request, $id)
    {
        // set the storage directory
        $directory = storage_path('videos/temp' . md5(now()));

        if (Video::where('project_id', $id)->first() == null) {
            $video = new Video;
        }
        else {
            $video = Video::where('project_id', $id)->first();
        }

        $upload = $request->file('video');

        $filename = 'video' . '.' . $upload->getClientOriginalExtension();

        $upload->move($directory, $filename);

        $video->storage_path = $directory . $filename;

        $project = Project::find($id);
        $video->project()->associate($project);

        $video->save();

        // $this->vimeo->upload($directory . $filename, false);

        return redirect()->back();
    }
21 Mar
4 years ago

themccallister left a reply on CSRF Issue When Trying To Upload A Video?

Also, the token is exactly the same on refresh...

themccallister left a reply on CSRF Issue When Trying To Upload A Video?

Same results after being cleared.

themccallister started a new conversation CSRF Issue When Trying To Upload A Video?

I'm using the Vimeo API wrapper from https://github.com/vinkla/vimeo.

When trying to use the facade Vimeo to upload the file (from the storage path) I am receiving this error:

TokenMismatchException in compiled.php line 2387:

My controller is rather simple, you can view it here: http://laravel.io/bin/Lk3d9. The local upload works fine. I can see and view the video in my local storage. However, as soon as I pass the information off to the Vimeo service provider, it throws that error, any ideas?

19 Mar
4 years ago

themccallister started a new conversation Converting Dates In Laravel 5

I have a few (I mean over 100) date fields on a Model. On the front end, the user is entering the data in the following format "03/19/15". However, since I wrote the schema using the 'date' column type, the data is being saved as '0000-00-00'. I understand why this is happening so heres my question.

Also, I am using form model binding so when the information is displayed from the database, it shows up with the Unix formatting.

What is the best way to convert the format of over 100 date fields? Both on save and show?

28 Feb
4 years ago

themccallister started a new conversation Using Form Requests To Abstract From Controller?

Just wondering if anyone gave this any thought... Lets say I have a controller that was responsible for creating a new Thing and assigning the 75 input items to the model...

Would using a form request, which I know is mostly for validation and authorization, a good use case to keep the controller clean?

So maybe a method on the form request like so:

$thing = new Thing;

$thing->one = $request->input('thing-one');
$thing->two = $request->input('thing-two');
$thing->three = $request->input('thing-three');
$thing->four = $request->input('thing-four);
// etc...

$thing->save();

Probably not the best use case for a form request but it crossed my mind. I'm probably just being nit picky...

themccallister left a reply on L5 Eloquent Query Question - Roles / Groups

I would give this a watch: https://laracasts.com/lessons/users-and-roles. While its not referred to as a "group" its essentially the same technique. I recently used the same process on an app with L5.

themccallister left a reply on Blade - Using Conditionals On A Relationship That Can Return Null.

Those both kind of do the trick.. But this design has multiple tasks per page and the design requires editing one task and saving, not one button for all... So it's kind of tricky template-fu.

themccallister started a new conversation Blade - Using Conditionals On A Relationship That Can Return Null.

So I ran into a huge tempting issue with Blade last night and was hoping for some help…

Here is a quick synopsis.

I have a template that needs to show and hide a section based on a conditional of a relationship… To keep it simple, I’m going to relate this as a Task app…

First, here is the controller:

$project = Project::with(’tasks')->findOrFail($id);

return view('projects.tasks', compact('project'));

When no tasks are present, it obviously returns a null value - expected.

Now the template it self needs to show a a button if no value is assigned to the task upload, as an example:

{{ $project->tasks->uploaded_document }}

In the template, I need to show an hide a button based on that condition (is there a document?), easy right? So I tried this:

@if(is_null($project->tasks->uploaded_document))
// show the upload a document button
@else
// show the link to the document

Pretty straight forward with a seeded database… Then the tricky part comes along… What happens when the he `t relationship is null? This error is thrown, and for good reasons…

Trying to get property of non-object

Because the tasks relationship is null… So there is my predicament, I can’t really change the template design - not my call. So, I’m sure there is a better way to handle this.. Anyone want to give it a go?