Member Since 2 Years Ago

Experience Points 30,490
Experience Level 7

4,510 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 255
Best Reply Awards 4
Best Reply
  • 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.


    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.


    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.

28 Sep
9 months ago

thc1967 left a reply on Migrations Table

When you run one of the php artisan migrate, Laravel will create the migrations table in the database you point to in the .env file.

However, you shouldn't care about its contents. It should be black-box to you. Laravel's artisan migrate commands manage that so you don't have to worry about it.

Learn more:

thc1967 started a new conversation Force Forge To Reload ENV?

How do I force Forge to reload the environment variables?

I've tried changing the environment variables through Forge. I've tried restarting Nginx, PHP, and the server. I've tried going into the web app via command line and running php artisan cache:clear and php artisan config:clear.

Nothing seems to reset the config / env cache.

How can I tell?

I change the APP_NAME. Doesn't appear to change when serving from my Forge managed server. When I change it in the .ENV file on my local dev box, a simple browser refresh refreshes the displayed APP_NAME.

14 Jul
1 year ago

thc1967 left a reply on MIME Detecting As Not TXT, But It's TXT - Email Info Inside

Yeah, I'm positive it's a text file because of the steps I took:

  1. Create a new file in my text editor, paste in the lorem only, save, upload -> works.
  2. Paste in the top 6 lines, save again, upload again -> rejected.
  3. Remove the top 6 lines, save again, upload again -> works.

Laravel is not actually only checking the mime type of the file. As far as I can tell from the searches I've done, it uses Symfony's mime type checker which evaluates file contents, too.

13 Jul
1 year ago

thc1967 started a new conversation MIME Detecting As Not TXT, But It's TXT - Email Info Inside

I'm using Laravel validation for an uploaded file. The validation string looks something like this:

'file_upload' => 'required|file|max:50000|mimes:zip,csv,doc,docx,gif,jpe,jpeg,jpg,json,log,pdf,png,ppt,pptx,saz,txt,xls,xlsx,xml',

When I upload almost any text file, this works great.

However, when my text file contains information you might ordinarily find in a text file that was copied / pasted or exported from an email message, the validation fails, I assume because the validator is peeking inside the text file to see that stuff.

Example of the content:

From:   Jane Smith <[email protected]>
Sent:   Friday, July 13, 2018 8:25 AM
To: John Smith
Cc: Alfred Smith, Zach Smith
Subject:    RE: You really have to see this awesome chain letter!

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec venenatis sem sit amet lorem cursus tempor. Cras dolor risus, efficitur quis justo posuere, tempus malesuada odio. Nullam cursus odio et orci molestie, at elementum ante sollicitudin. Curabitur sagittis dignissim nisi, ut tincidunt leo maximus non. Duis auctor est nisi, ut porta erat aliquet ut. Proin porttitor volutpat ante. Sed ornare turpis volutpat ex commodo elementum. Donec interdum, urna vitae faucibus ultrices, magna massa iaculis lorem, eu venenatis nisl arcu nec justo. Sed malesuada eros neque, eget mollis sem fermentum a. Donec porttitor tincidunt ligula, vitae tincidunt eros facilisis quis.

So when my text file contains those first 5 lines, validation fails. When my text file does not contain those first 5 lines, validation passes.

I do not want to include .msg into the MIME list because I don't want to upload .msg files. However, text files that really are just plain old text files even if they're exported from an email system are fine.

Please tell me I don't have to write a custom validator for this. There has to be a bettery way?

Thank you,

29 May
1 year ago

thc1967 left a reply on Is Any Key In Array

Silly me... it's not a Collection. It's a MessageBag. ->hasAny()

thc1967 started a new conversation Is Any Key In Array

I'm trying to determine if an array or collection has any one of several keys in it. My use case is that I want to put a badge on a tab to signify if any of the fields in that tab has an entry in the $errors collection.

I've tried:

$errors->has(['key1', 'key2', 'key3'])

But that only returns TRUE if the collection has ALL the keys; not any one of them.

I suppose I could do something like this:

@if ($errors->has('key1') || $errors->has('key2') || $errros->has('key3'))

...but that feels kind of gross.

I have to be missing something, yes?

07 Apr
1 year ago

thc1967 left a reply on Putting .ENV Variables Into A Database Table?

@ricardovigatti it doesn't matter what's in my .ENV file. The only thing from it that I technically cannot store in the database is the connection information for the database.

I understand that the .ENV file is designed to hold environment-specific configuration that changes infrequently, or hopefully only is different per environment. But it might still be more convenient for me to store it in a database, especially since I don't want a .ENV file full of configuration sitting out there on a production server. I can either use server capabilities to configure dozens of .ENV entries, or use that to configure the handful of settings I need to connect to the database and pull the rest from the database.

06 Apr
1 year ago

thc1967 started a new conversation Putting .ENV Variables Into A Database Table?

I've been pondering the possibility of putting all of the .ENV configuration I have, except the database connection of course, into a database table.

It seems like it would be easier for me to manage there, and the only thing that really needs to be at the environment level to do that is the database connection.

I understand I'd have to make sure all my config files would need to pull from the database as appropriate.

I would also, of course, have to cache the settings... which seems like it happens anyway.

What's the drawback to this approach? It obviously isn't the standard and there seems to be little information on the Web about doing it, so nobody is doing it.

Why isn't it the standard? What am I missing?

20 Mar
1 year ago

thc1967 started a new conversation UploadedFile::fake()->image(...) Failing In Controller Validation

My controller validation:

$validations = [
    'name' => 'required|string|min:3|max:64|unique:'.$system->getTable(),
    'file_upload' => [

My PHPUnit test:

$item = make(System::class);

$postData = collect($item->toArray())->merge([
    'file_upload' => $file = UploadedFile::fake()->image('logo.gif', 60, 30),

$this->post(route('', $postData->toArray()));

The result: Two messages in my session error bag:

  • The file upload must be an image.

  • The file upload must be a file of type: image/jpeg, image/png, image/gif.

08 Mar
1 year ago

thc1967 left a reply on Calling My API From My Web Site

To answer my own question. one way to do it at least...

  1. I added Passport into my Laravel (5.6) project just like the docs say to. There are a lot of steps with a lot of detail to this.

  2. In my User class, I overrode the HasApiTokens.token() method to be named passportToken(). Why? Because I wanted use the name, token() myself.

use HasApiTokens {
    token as protected passportToken;
  1. Also in my User class, I created a token() method to cache the token to the session and ensure I have one. Still need to ensure it hasn't expired.
public function token()
    $token = $this->passportToken() ?: session('api-token');

    if (!$token) {
        $token = $this->createToken('local')->accessToken;
        session(['api-token' => $token]);

    // TODO: Ensure it hasn't expired

    return $token;
  1. In my master layout (importantly the spot I'm putting HTML meta tags), I add a tag for the API token if I have an authenticated user.
<meta name="api-token" content="{{ auth()->user()->token() }}">
  1. In my bootstrap.js file, if I have the meta tag from the previous step, add an Authorization header into the Axios headers array that contains the API token. This is what Laravel Passport wants to see.
let apiToken = document.head.querySelector('meta[name="api-token"]');
if (apiToken) {
    window.axios.defaults.headers.common['Authorization'] = 'Bearer ' + apiToken.content;

thc1967 left a reply on Calling My API From My Web Site

I tries using just auth, too. Didn't work. I want to keep auth:api anyway so I can provide an API. If I'm going to do that, I might as well leverage Passport.

I got it working with Passport to the point that the API end point returns what I expect it to. There still seem to be some issues with remembering the token, but at least I think I'm on the right track.

thc1967 left a reply on Calling My API From My Web Site

@Cronix yeah, I was headed down that path but it seems weird to have my own web app that contains my API have to authenticate again like it's a separate application.

Digging through Passport's HasApiTokenscode, it seems like I might be able to do something similar to the way the boilerplate Laravel "bootstrap.js" handles the CSRF token with a Passport Personal Access token. But that seems like it's too hard, too, which usually means I'm doing something wrong. :)

thc1967 left a reply on Calling My API From My Web Site

The result of the file_get_contents() call is a 500 error when I call it from my routes/web.php like so:

Route::get('/apitest', function () {
    $data = file_get_contents('---my api url---');

If I remove the auth:api middleware in the API route group, it works just fine... but I don't think that's wise.

I need to understand how to pass that auth:api middleware check in my API when calling from Axios within my own web site. Is it Passport or maybe JWT or something easier?

thc1967 started a new conversation Calling My API From My Web Site

I'm trying to do something that seems way harder than it should be. Either I'm not Googling the right keywords or this is a stupid way to do things.

I'm trying to call my own API (routes defined in/routes/api.php) from within my own web page.

For a use case example, let's use the ubiquitous Forum example.

Let's say that I have a view (/views/posts/index.blade.php) in which there is a Vue component that displays a data grid. It uses Axios to get the data for the grid from my API.

So I want to create an API endpoint like /api/v1/posts that returns the posts in JSON format.

The problem that I keep running into is that my server returns a 401 (unauthenticated) error when I try to do this.

in my /web/api.php, I have:

Route::group(['middleware' => 'auth:api'], function () {
    Route::group(['prefix' => 'v1'], function () {
        Route::get('characters/', '[email protected]');

In my page I include a Vue component that displays a table. Doesn't matter, we never get there. In the Vue component's loadData() method, I have:

    .then(function (response) {...})
    .catch(function (err) {...});

When I load the page, I'm automatically calling that loadData() method. The response I get in the JavaScript console on Chrome is that the URL returned a 401 (Unauthorized). This is confirmed in the Network tab in Chrome developer tools, as well. I need to figure out Passport to make this work? Or am I thinking about this wrong?

18 Oct
1 year ago

thc1967 left a reply on Testing A Digest - Email Content

I think I clicked too quickly. Sigh.

So I like the idea of having a separate digest creator. In fact, I think that's what I must do. $mail->items is nothing. I can see the things that I attach to the Mailable if I dump() it, but they wind up as protected properties so I can't look at them in the test.

10 Oct
1 year ago

thc1967 started a new conversation Testing A Digest - Email Content

Hi again.

Today, I'm writing code that sends an email digest. To stay with the ubiquitous forum example everyone is familiar with, let's say that Users can Subscribe to get Notifications when Posts or Comments are created. Let's also say that we want to do this in daily digest format instead of immediately upon creation.

This means that I have to periodically create email and when I do that, I need to ensure that the Posts and Comments of interest to the User are included in the email while those that are not of interest to the user are excluded.

I already know how to code the email generation. I can generate the mail digest no problem.

What I don't know is how to write the unit test to dig into the body of the email to ensure that I see the information I expect to see and do not see the information I expect to be absent.

I can do something like this to verify that we send to the user I expect, but how do I interrogate the body of the email?

public function digest_email_filters_to_subscribed_posts()
    // Do my setup


    // Do the thing that would send the emails

    Mail::assertSent(PostDigest::class, function ($mail) use ($user) {
        return $mail->hasTo($user->email);

I think has a package that might let me test this, but I wanted to stick with core Laravel if it's possible there.


08 Oct
1 year ago

thc1967 left a reply on Migrate & Seed Only Once?

I think I have it working with the Laravel DatabaseTransactions trait... mostly.

MySQL behaves differently than Sqlite when using transactions. The biggest change seems to be that when we consume an autonumber in MySQL, that autonumber stays consumed. This invalidates tests like ensuring I've redirected to a specific record ($this->assertRedirect(route('', 1))). The ID of the record would only be 1 for the very first test that I run that creates the object.

This is more proper database behavior, of course, but it means I need to rethink my test cases a little bit.

07 Oct
1 year ago

thc1967 left a reply on Migrate & Seed Only Once?

Actually, the make(Comment::class) calls create(Post::class) which does persist it to the database...

...but it doesn't because it's all transacted because I'm using the transaction trait in my test.

So my theory is that the the data created during the transaction that started in my test class isn't able to be seen in my controller, which I'm almost certain is running in a separate process from my test class.

thc1967 left a reply on Migrate & Seed Only Once?

$item = make(Comment::class); // Creates a Post behind the scenes.

$this->post('/comments/store', $item->toArray()); // Touches the Post

The $this->post() results in a 500 error, which comes back as a referential integrity constraint violation because the Post that the Comment created doesn't exist within the context of the controller.

I think that's because I'm running the transaction within the Test object, which is a different memory space than the Controller, so the Controller isn't aware of the transaction...

Unfortunately, I'm distracted with other things so I've had to stop digging. Will be back to it later this weekend hopefully.

thc1967 left a reply on Migrate & Seed Only Once?

That's a cool idea.

Unfortunately, transactions do not seem like they're going to work because of the context switch when testing controllers with objects that have relationships.

I'm creating the related objects in my test case, but those relations don't carry through into the controller when I call it with something like $this->post($route, $params). Therefore, I bomb out on referential integrity constraints in my controller.

Maybe if I do it without transactions. Do a migrate:fresh --seed before each run of my full test suite and just let the tests load up the database. Doesn't matter; it's a test database, right?

06 Oct
1 year ago

thc1967 started a new conversation Migrate & Seed Only Once?

I've finally bumped into a spot in my project that I can no longer use an in-memory sqlite database for my unit tests. It was cool while it lasted but, alas, I need to do some stuff that sqlite simply doesn't support.

And I want to keep using unit testing. I'm pretty stoked that I have hundreds of tests with thousands of assertions. I've found it helps tremendously with everything I do.

And I refuse to design my code around shortcomings in the testing setup I've elected to use. My code needs to be right and the tests should support and verify that; not the other way around.

So now I face the prospect of running my unit tests against a real, "on-disk" database like mysql (same thing I'm using for production).

With a sqlite memory database, I didn't have to worry or care about exactly how the tests would run the migration and the tiny little seeder I set up. If it ran them before each test class or even each function, that wouldn't be a big deal. It's all in memory.

That won't be the case any longer.

How, using Laravel 5.5, do I ensure that my PHPUnit tests run my migration and seed just once before running all the test classes & methods?

Thanks for the advice!

30 Sep
1 year ago

thc1967 left a reply on How To Get Array Of Fields That Have Been Updated

Call $this->getDirty() to get the elements that are changing and the values they're changing to.

The Eloquent model will only return an array from that method if you have not yet persisted the record.

$user = User::findOrFail(1);
$user->name = 'a new name';
$user->getDirty(); // ["name" => "a new name"]
$user->getDirty(); // []

thc1967 started a new conversation My Array-fu Is Weak. Is There A Better / More Efficient Way To Do This?

In an Eloquent Model class...

        $changing = collect($this->getDirty());
        $originals = collect($this->getOriginal())->intersectByKeys($changing);
        $mapped = collect([]);

        $changing->each(function ($item, $key) use ($mapped, $originals) {
                $key => [
                    'new' => $item,
                    'old' => $originals[$key],
22 Sep
1 year ago

thc1967 left a reply on Local Scopes Functioning Apparently Intermittently


return static::forSearch()->addSelect([...

Sometimes you just have to look at it in a different context to see the obvious.

thc1967 started a new conversation Local Scopes Functioning Apparently Intermittently

In my Model-derived class, I have added two query scopes:

public function scopeForSearch($query)
    $query->leftJoin('clients', '', 'tickets.client_id')
        ->leftJoin('users as submitter', '', 'tickets.submitted_by')
        // blah blah blah stuff here is irrelevant
            ' as client_name',
            // blah blah blah more irrelevant detail here
    return $query;

public function scopeForDownload($query)
    return $query::forSearch()->addSelect([
        'issue_types.sort_order as issue_type_sort_order',
        // blah blah irrelevant list of stuff

Then off to my PHPUnit test class:

/** @test */
public function scope_for_search_returns_related_name_values()
    $t = create(Ticket::class);

    $tickets = Ticket::forSearch()->get();

    $this->assertCount(1, $tickets);

/** @test */
public function scope_for_download_returns_related_table_values()
    $t = create(Ticket::class);

    // BadMethodCallException: Call to undefined method App\Models\Ticket::forDownload()
    $tickets = Ticket::forDownload()->get();  

    $this->assertCount(1, $tickets);

The problem?

The line in scope_for_download_returns_related_table_values throws an exception. The scope for search test works fine.

What'd I do wrong?

20 Sep
1 year ago

thc1967 left a reply on Traversing Multiple Many-to-many Relations

No, not for the application I'm writing. This is without a doubt the right data model. Clients can share users. When a user logs in, I want them to easily see all their clients and all their products associated to all their clients. There is also plenty of other stuff that I'm tracking that needs to relate to both and trying to split clients & users out into a separate database per client would be brutal for the rest of the app.

I don't know why I'm trying to save a few simple queries when the ORM is so chatty anyway, but I'm pretty sure I can do it with inner joins.

That solution is more SQL than "Eloquent", but I can't figure out an Eloquent implementation that gets me down to one query instead of one query per client associated to the user + the products query afterward.

19 Sep
1 year ago

thc1967 started a new conversation Traversing Multiple Many-to-many Relations

Say I have set up my data model such that a user has multiple clients and a client has multiple products. My tables look something like this:

users -> client_user -> clients -> client_product -> products

What's the most efficient way, given a user, to get the list of (distinct) products?

I looked over the documentation for hasManyThrough() but that seems to require a 1:M relationship.

I could use raw queries, I suppose, but there seems like there should be a better, "Eloquent" way.


10 Sep
1 year ago

thc1967 left a reply on Many-To-Many Detach Sometimes Fails

Based upon additional testing I've done to narrow it down, it looks like it's a bug in the framework.

If you call ->detach([...]) after loading the relationship, the framework correctly deletes the rows from the pivot table but does not remove the records from the in-memory object you called it on.

thc1967 started a new conversation Many-To-Many Detach Sometimes Fails

My Models are User and Client with a Many to Many between them. Both sides implemented as a $this->belongsToMany().

In the following code the second method to detach seems to fail. The records do seem to be removed from the database because those assertions pass; however, the final assertion that they're actually gone from the Model fails.

The failure on that last assertion only occurs for the second method of detaching. The first and third methods pass that assertion, too.

Why does the second fail?

/** @test */
    public function basic_user_client_detach_test()
        $user = create(User::class);
        $clients = create(Client::class, [], 2);

        // Method 1 works.
        // Method 2 does not detach.
        $intersectingClients = $clients->intersect($user->clients);
        // dd($intersectingClients->pluck('id')->toArray());  // ->  [0 => 1, 1 => 2]

        // Method 3 works.

        // These pass for all 3 methods.
        $this->assertDatabaseMissing('client_user', [
            'client_id' => $clients[0]->id,
            'user_id' => $user->id,
        ])->assertDatabaseMissing('client_user', [
            'client_id' => $clients[1]->id,
            'user_id' => $user->id,

        // This fails for Method 2.
        $this->assertEquals(0, $user->clients->count());


08 Sep
1 year ago

thc1967 left a reply on Testing And Apostrophe Characters In Fields

That does the trick. Thanks!

thc1967 started a new conversation Testing And Apostrophe Characters In Fields

I get tests that fail every so often because of the way the system, not sure what part, handles apostrophes.

When I use $faker->name, I often get something with an apostrophe, and it's most often O'Connell.

When this happens, my tests that do an ->assertSee($model->name) fail because what actually goes into the HTML is O&#039;Connell.

What's the best way to avoid these phantom failures?


02 Sep
1 year ago

thc1967 left a reply on Passing A Variable Into A Blade @include - Variable Not Defined

OK this totally doesn't make sense. When I do a simple test with it, even nesting includes and sections relatively deeply, it works.

It doesn't work in more complicated code.

thc1967 started a new conversation Passing A Variable Into A Blade @include - Variable Not Defined

This seems to be the way the documentation suggests to do it.

In my parent Blade template, I have:

 @include('layouts.forms.btnsavecancel', ['cancelRoute' => '/'])

In the layouts.forms.btnsavecancel, I have:

<a class="button" href="{{ $cancelRoute }}">

The result in Whoops is a variable not defined error on $cancelRoute.

This is using Laravel 5.5. Documentation I referenced:

23 Aug
1 year ago

thc1967 left a reply on TDD Forum Lesson 29: Vue Component Not Displaying

Well, I'm certain the Vue component gets loaded as a Vue component else it wouldn't show up in the Vue debug tool in the browser.

And wth... apparently my classes are not correct. Thanks for bringing me back around to the obvious. :)

thc1967 started a new conversation TDD Forum Lesson 29: Vue Component Not Displaying

I've actually used Vue pretty successfully so far, but for some reason at the first point in Lesson 29 that we build the site with the Vue component, it is not displaying in my page.


    <div class="alert alert-success fade show" role="alert">
      <strong>Success!</strong> {{ body }}

    export default {
        data() {
            return {
                body: 'You forgot to set body'



window.Vue = require('vue');

Vue.component('flash', require('./components/Flash.vue'));

const app = new Vue({
    el: '#app'

What it does in my browser (Chrome on Windows 10) is... no display. Console shows no errors. Vue toolkit shows that the Vue object is there and has the data I expect. When I hover the component in the Chrome Vue utility, it highlights where it should be on the web page, but it simply does not display at all.

What did I miss?

17 Aug
1 year ago

thc1967 started a new conversation Kind Of A Gross Functional Test. How To Improve It, Maybe?

GIVEN that we have a Character with a Type that has a Might pool value and a Descriptor that has a Might bonus value WHEN we run that character through the calculation rules for rendering THEN the Character's Might will be calculated accurately

    public function it_calculates_might_accurately()

        $stat = Stat::findOrFail(Stat::MIGHT);
        $type = create(Type::class);
        $type->stats[0]->pivot->pool = 10;

        $descriptor = create(Descriptor::class);
        $descriptor->stats[0]->pivot->bonus = 2;

        $characterModel = new ModelCharacter();

        $characterRender = new RenderCharacter($characterModel);

        $this->assertEquals(12, $characterRender->stats[Stat::MIGHT]->pool);

Laravel 5.5. The only thing I seed into the database for my tests is the core rule stats.

I probably don't need the signIn() since I'm never saving the character.

14 Aug
1 year ago

thc1967 left a reply on What Are You Working On ?

I'm toying with a few.

I recently rewrote my wife's main web site using Laravel. I need to get around to her secondary site after October.

I've been up & down writing / re-writing a defect tracking application for the company I work for as I try to learn Laravel and Vue better. I think in the end, this one is a waste of time. I mean, our current system is homebrew, ancient, and craptastic. We're not going to buy one, so that's out. But our IT manager hates Linux with a passion so he'll never deploy what I write either. (Maybe if I can figure out how to do scheduled events on Windows...)

Finally, I'm working on a character generation and management web app for a table-top RPG that I enjoy playing. This one is a huge learning experience because of all the weird one-off rules embedded in otherwise neatly aligned design. This one is probably a dead-end, too, because I doubt the publisher will be interested in a partnership where I do all the work and they take a portion of the profit.

11 Aug
1 year ago

thc1967 left a reply on Best Practice For Controllers

I would probably use method #2 simply because I like to stick to the HTTP action verb method names. Plus it's more familiar for me to control with policies / gates.

I'm relatively new to this though so don't take that as a great answer. I'm interested to see what more experienced developers than I have to say.

04 Aug
1 year ago

thc1967 left a reply on Eloquent Get All And Count

Your controller confuses me. You're running a query in the for loop but not doing anything with the results. Since $send is the iterator on the loop, I suspect it would be null by the time you pass it to the view.

If you're a subscriber here, there is a video maybe 25% of the way through (as of this writing) the TDD Forum series that shows you how to return a count of a related relationship when you load values into a model. I think that could work for you. If you implemented it, your controller code could be 2 lines - get the result list and return the view.

Look for the video that covers addGlobalScope().

03 Aug
1 year ago

thc1967 left a reply on Question About Paypal Express Checkout, Braintree, And Stripe.

You should use the one your customers will favor. Assuming you can't offer options, that is. Plenty of sites use an "internal" (seems like Stripe) processor and offer a PayPal option.

I hate PayPal with the searing fire of 10,000 suns... but that's what I use on my wife's sites because that's what her customers are far and away most comfortable with.

30 Jul
1 year ago

thc1967 left a reply on What Kind Of Web Hosting I Would Need To Deploy Laravel And Php Websites ?

Others have suggested you can't use shared hosting. You can, but you need the right one. The main things you need are the minimum requirements (PHP version, database, etc.). It's helpful to be able to set the home directory for each site you host. I have Laravel sites hosted on shared hosting and it works.

However, it's probably much easier for you to use a cloud-based server and provision it and deploy your software with Forge. Add Envoyer if zero downtime is a requirement.

26 Jul
1 year ago

thc1967 left a reply on Relationship Help - Coach -> Teams -> Players

You haven't established a direct relationship between coaches and players. You have to go through teams. Think more along the lines of:

$players = coach->teams->players;

(May not be exactly syntactically correct.)

22 Jul
1 year ago

thc1967 started a new conversation Compiling Promises For IE11

I'm stuck. Need help.

I'm using Laravel 5.4, Vue, and Axios. In my Vue components, I use Axios to make Ajax calls, and those calls use Promises.

I believe there's a way to compile that all down using mix (or elixir?) so that the Promise constructs are smushed down into a script that IE11 supports, but I can't figure out how to do it.

I'd appreciate advice, point me to lessons here, point me to tutorials on the internet, whatever.

Here's an example of my use of Promises in Axios within a Vue component (this function dynamically loads a Vueified SELECT):

        loadList(uri) {
            // Cache the current value so we can put it back
            // after loading the list.
            this.isLoading = true;
            var cacheValue = this.myValue;
                .then( (response) => {
                    this.list = this.transformList(;
                    this.myValue = cacheValue;
                    if (!this.myValue && this.initialValue) {
                        this.myValue = this.initialValue;
                    this.isLoading = false;
                .catch( (error) => {
                    this.list = [];
                    this.isLoading = false;

Here's my app.js that loads my Vue components:



window.Vue = require('vue');

// Third-party components
Vue.component('vue-draggable', require('vuedraggable'));
Vue.component('date-picker', require('vuejs-datepicker'));

// My components
Vue.component('active-tabs', require('./components/ActiveTabs.vue'));
Vue.component('pagination', require('./components/Pagination.vue'));
Vue.component('paginated-table', require('./components/PaginatedTable.vue'));
Vue.component('notification', require('./components/Notification.vue'));
Vue.component('data-select', require('./components/DataSelect.vue'));
Vue.component('sort-dialog', require('./components/SortDialog.vue'));

Finally, here's my webpack.mix.js that compiles everything down:

mix.js('resources/assets/js/app.js', 'public/js')
   .js('resources/assets/js/zxcvbn.js', 'public/js')
   .js('resources/assets/js/cleave.js', 'public/js')
   .js('resources/assets/js/vuemain.js', 'public/js')
   .js('resources/assets/js/vuecrud.js', 'public/js')
   .sass('resources/assets/sass/app.scss', 'public/css')
   //TODO: .version()
21 Jul
1 year ago

thc1967 left a reply on Database Structure Advice

Cardinality is the number of unique values in a column. Typically a database engine will use an index on a column only if the cardinality is advantageous to it. The general rule of thumb is that if any one value in the column comprises more than about 7% of the table's inventory, it won't use the index. This does vary by database engine and other factors.

However, given a column with a cardinality of 2, you're guaranteed that at least one of the values has way over 7% of the inventory of the table, so you probably will not use an index on that column.

A showplan is a tool in the database engine that lets you evaluate the plan the database engine generates to resolve a query. Among other statistics and information, it will show you the index or indices the database engine will use to resolve a query.

thc1967 left a reply on Database Structure Advice

It seems unlikely that your database would leverage an index on a column that has a cardinality of 2. Might want to showplan that to see if you're wasting space there.

10 Jul
2 years ago

thc1967 left a reply on Load A Laravel App In An Apache Server

I found that same link on StackOverflow and promptly ignored it.

Does your hosting provider let you change the default root for a web site? I discovered that mine does, right through CPanel. I dropped my Laravel app in just like it was and pointed the document root to /myapp/public.

You should also check if the host offers SSH access. Mine does but I had to ask for it. This will let you do the command-line things.

If your host doesn't offer either of those, you might consider changing hosts. Depending on your capabilities and scope of the site, it might be worthwhile to consider a cloud host so you have complete control over the box, rather than a shared host where you have minimal control over the box.

thc1967 left a reply on Laravel Training

Not sure if a 7 page troll, but...

My first exposure to Laravel was when it first came out. Version one point oh. That thing... I could not understand that thing. I had been a developer for a good 20 years by that point. I understood the MVC pattern. I had a reasonable handle on PHP. But... just... nope. Brain couldn't hack it.

Next opportunity I had to explore Laravel again was after 5.4 came out. Holy night and day, Batman! Laravel 5.4 is awesome!

And I found the FREE up-to-speed on Laravel 5.4 course that Laracasts offers to be such a boon that I ordered the T-shirt. (And it's a really nice t-shirt!)

I'm normally not a visual / video learner. So I fired up my trusty dusty Apache server with some PHP and MySQL and I followed along with Jeffrey through that course. I paused him every once in a while and wandered off into the weeds on my own. It worked out pretty well, with Jeffrey building block after block and me figuring out how Laravel really worked and what its capabilities and boundaries are.

As to, "Why Laravel?", well, your employer dictated it. The, "Why?" is to remain gainfully employed, assuming you want to do that with this particular employer.

Others have chimed in with other reasons, too. It's nice not to have to worry about the rote framework crap when I code. It's nice to have the MVC structure in place for me to extend. It's nice to write one line of code to establish a relationship between two objects that "just works" everywhere I want to use it. It's actually kind of a fun framework to use, and I wish I could use it at my job full-time.

And that's kind of the kicker there. The Laravel team is writing the framework not only that they WANT to use, but that they DO use every single day. I look at that sort of like I look at computer games. My favorite games are the ones that are written by programmers because they want to play the games, not (just) because they're getting a paycheck. That's how I view the team that produces this particular framework, and it makes all the difference in the world.

Another answer to, "Why Laravel?" can be found in Matt Stauffer's book, "Laravel Up and Running". The free sample is the chapter titled, surprisingly enough, "Why Laravel?" Read it here:

07 Jul
2 years ago

thc1967 left a reply on Struggling To Understand The Concepts Of Laravel And Frameworks, Can You Help?

Why use a framework?

I've worked in the software industry for almost 30 years, first as a developer and now as a project manager. I've really grown to appreciate Laravel and Lumen.

Good frameworks like Laravel are a jump-start to development. They offer great value by doing things for you so you don't have to code it yourself. If their developers are active, they constantly grow and expand and improve.

They do come with some trade-offs. There's a learning curve. They usually offer a certain way to do things, and if you want to take advantage of the benefits they offer, you need to stick roughly to the agenda. They may not be perfectly optimized for performance for your application.

But when it comes right down to, "What do I want to develop using?", I pull Laravel and Lumen out of the toolkit to launch some projects.

My company develops enterprise application software for which we frequently need to create custom web service hooks into client line of business systems. I can whip up a test harness for those web services in a matter of hours, or a day for something relatively big and complicated, using Lumen. Write that from scratch? Never going to happen.

I also manage a couple of web sites for my wife's business. I recently rewrote one of them in under 4 hours using Laravel. The last rewrite before that one took weeks.

I'm not a professional PHP developer. Never have been. It was always C, C++, VB (shudder), and Java. But when the time for semi-retirement comes, I'm looking forward to being a part-time, work-from-home PHP developer and leveraging the hell out of Laravel to stay competitive with the young whippersnappers.

30 Jun
2 years ago

thc1967 left a reply on Building A History Of Data Changes

I would prefer to manage the record as a whole instead of creating the equivalent of a row per field. If I have new and old together, I can show them side-by-side and do cool things like filter to only populated values or only changed values.

I don't think I'll be high enough volume that I need to worry about purging or storage. The system that I'm replacing has been in place for over 15 years, it tracks history as 1 record per 1 field change, and it has under 500,000 records in its history table.

So let's change the question...

If I have a JSON representation of an Eloquent model inside a field in a table, how would I reconstitute that into the right Eloquent model object in PHP / Laravel? I feel like I should be looking into how polymorphic relations work...

thc1967 started a new conversation Building A History Of Data Changes

I'd like to build a history feature into my application such that when a user updates one of my objects / records, I track that as an event that also stores the original values on the object and the updated values on the object.

I'd like to be able to come back around to look at that using the objects themselves, so I think that means I would need to store the data in a way I can read it back.

I'd like to do this without too much variance from the way Laravel and Eloquent manage the Model - Table relationship, so I think that precludes doing something like storing multiple copies of the record in the model's table.

I thought about creating a history table of sorts and storing the pre-edit and post-edit versions of the Eloquent model object as JSON (or something else?) in two different fields, creating a new record each time there was an update. I got about that far and thought it would be cool to do that but I couldn't figure out how to reconstitute an Eloquent Model object from JSON sitting in a record in a table.

What techniques have you guys used to do this with Laravel?