thetoad01

thetoad01

Software Architect at Newtech Automotive Services

Member Since 1 Year Ago

Experience Points
63,060
Total
Experience

1,940 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
619
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.

Level 13
63,060 XP
Jan
15
1 week ago
Activity icon

Replied to Form Not Getting Data From Database

If you dd($request->all()); what is the output?

You may have an array and have to get the data like $request['vegan'].

Activity icon

Replied to Collections Filter Need To Return 0 Values?

Found my own solution. I was using the wrong method. Using each() adds the age even if it is 0.

$inventory = $inventory->each(function ($value, $key) {
    return $value->age = Carbon::now()->startOfDay()->diffInDays(Carbon::parse($value->stock_date));
});
Activity icon

Replied to Collections Filter Need To Return 0 Values?

Clarification:

Here is a sample of the output from 2 items in the collection after then have been run through the collection filter from the first post:

#items: array:2 [
  0 => . . . 
       #attributes: array:12 [▼
        "id" => 3362
        "store_number" => "11094"
        "stock_number" => "10164A"
        "vin" => "1GNFK26369R225914"
        "type" => "Used"
        "stock_date" => "2020-01-13"
        "deleted_at" => null
        "deleted_source" => null
        "created_at" => "2020-01-14 18:00:02"
        "updated_at" => "2020-01-14 18:00:02"
        "certified" => 0
        "age" => 2
      ]
      #original: array:11 [▼
        "id" => 3362
        "store_number" => "11094"
        "stock_number" => "10164A"
        "vin" => "1GNFK26369R225914"
        "type" => "Used"
        "stock_date" => "2020-01-13"
        "deleted_at" => null
        "deleted_source" => null
        "created_at" => "2020-01-14 18:00:02"
        "updated_at" => "2020-01-14 18:00:02"
        "certified" => 0
      ],
  1 => . . . . 
      #attributes: array:12 [▼
        "id" => 3362
        "store_number" => "11094"
        "stock_number" => "10164A"
        "vin" => "1GNFK26369R225914"
        "type" => "Used"
        "stock_date" => "2020-01-13"
        "deleted_at" => null
        "deleted_source" => null
        "created_at" => "2020-01-14 18:00:02"
        "updated_at" => "2020-01-14 18:00:02"
        "certified" => 0
        "age" => 2
      ]
      #original: array:11 [▼
        "id" => 3362
        "store_number" => "11094"
        "stock_number" => "10164A"
        "vin" => "1GNFK26369R225914"
        "type" => "Used"
        "stock_date" => "2020-01-13"
        "deleted_at" => null
        "deleted_source" => null
        "created_at" => "2020-01-14 18:00:02"
        "updated_at" => "2020-01-14 18:00:02"
        "certified" => 0
      ]
...
]

As you can see, the age has been added to the collection.

Now when the original inventory collection has any stock_date of today, the age will equal 0 and the filter method on the collection removes all of them.

I need to get all of the inventory returned with the age pushed onto the collection.

Activity icon

Started a new Conversation Collections Filter Need To Return 0 Values?

I am using the filter method to push "age" onto a collection.

$inventory = $inventory->filter(function ($value, $key) {
    return $value->age = Carbon::now()->startOfDay()->diffInDays(Carbon::parse($value->stock_date));
});

The problem is that any inventory that was added today, hence an age of 0, does not get returned with the new collection. How can I get the inventory with age 0 to show up?

Jan
03
3 weeks ago
Activity icon

Replied to Laravel Data Fetching Help.

You could filter the returned collection.

Perhaps change ->having('mark', '>=', '$passMark')

to ->with('mark')

$filtered = $data->filter(function ($value, $key) use ($failMark, $passMark) {
    if ($value->mark) {
        return [
            $value->passed = $value->where('mark', '>=', $passMark)->count(),
            $value->failed = $value->where('mark', '<', $failMark)->count(),
        ]
    }
}
Dec
20
1 month ago
Activity icon

Awarded Best Reply on Dynamic Route Name In Blade Foreach

I got it to work. I had 1 route that was undefined that's why it blew up every time I tested.

<a href="{{ route('reports.inventory.' . \Str::slug($count['name']) . '.index', ['filter' => 'false']) }}">View Report</a>
Activity icon

Replied to Dynamic Route Name In Blade Foreach

I got it to work. I had 1 route that was undefined that's why it blew up every time I tested.

<a href="{{ route('reports.inventory.' . \Str::slug($count['name']) . '.index', ['filter' => 'false']) }}">View Report</a>
Activity icon

Replied to How Can Change Class With Method Or Filter ?

I didn't test this. Just a suggestion.

data() {
    return {
        itemFound = false,
    }
}
<div v-bind:class="[itemFound ? itemFoundClass : '']">
Activity icon

Started a new Conversation Dynamic Route Name In Blade Foreach

Example report route (there are many):

Route::namespace('Reports')->prefix('reports/inventory')->name('reports.inventory.exterior-color.')->group(function () {
    Route::get('exterior-color', '[email protected]')->name('index');
});

In the blade file there is a loop:

@foreach ($needs_attention as $key => $value)

I want to do something like this:

<a href="{{ route('reports.inventory.\Str::slug($key).index, ['filter' => missing]) }}">View Report</a>

I cannot get it to work. Any suggestions would be great!

Oct
07
3 months ago
Activity icon

Started a new Conversation Guzzle Post Boolean

When sending a post request with Guzzle it appears to be converting the boolean to a string and I cannot find a solution.

The form has a checkbox named "active".

$validated = $request->validate([
    'store_number' => 'required|max:10',
]);

$query = [
    'store_number' => $validated['store_number'],
    'active' => $request->active ? true : false,
];

$client = new Client();
$response = $client->post($url, [
    'headers' => [
        'x-api-key' => 'xxxxxx',
        'Accept'    => 'application/json',
        'Content-Type'    => 'application/json',
    ],
    'query' => $query
]);

When I dd($query), "active" is a boolean.

However, I get an error from the api because it is receiving "active" as a string. What am I missing?

Aug
19
5 months ago
Activity icon

Started a new Conversation NGINX No Input File Specified

I am working on a legacy project where I cannot change the paths that use the .php extension. When developing locally and using php artisian serve I can use routes such as:

Route::get('/zipcode/get-zipcode-info.php', 'Zipcodes\[email protected]tZipCode');

Then the request in my browser: http://127.0.0.1:8000/zipcode/get-zipcode-info.php?zipCode=06111

This works! I was very excited.

Then I deployed the code to our test server and get: "No input file specified."

The test server is running Nginx on Ubuntu 18.04

We have not been able to figure out how to set the config for the virtual host on Nginx to be able to ignore the .php extension and pass it along as a string to the route.

        listen 80;

        root /var/www/html/appdev/public;
        index index.php index.html index.htm;

        server_name appdev.newtechautomotiveservices.com;

        location ~ \.php$ {
                fastcgi_pass unix:/run/php/php7.3-fpm.sock;
                include fastcgi_params;
                fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_param   SCRIPT_NAME     $fastcgi_script_name;
        }

        location / {
                try_files $uri $uri/ /index.php?$query_string;
        }
}