MThomas

MThomas

Member Since 4 Years Ago

Eindhoven, The Netherlands

Experience Points 106,570
Experience Level 22

3,430 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 783
Lessons
Completed
Best Reply Awards 59
Best Reply
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

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

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

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

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    Laracasts Evangelist

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

  • Chatty Cathy Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

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

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

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

23 May
1 day ago

MThomas left a reply on How To Configure Laravel Passport's '/oauth/token' Rate Limit?

Isn't this what you are looking for: https://laravel-news.com/laravel-5-6-dynamic-rate-limiting

Route::middleware('auth:api', 'throttle:60,1')->group(function () {
    Route::get('/user', function () {
        //
    });
});
18 May
6 days ago
17 May
1 week ago

MThomas left a reply on VUE.js | Reload Page On External Server After Update.

You need to inform the client (that is where the JavaScript is rendered) that it needs to refresh. You can do this using Broadcasting in Laravel. You’ll need a service like Pusher or Laravel-Websockets to make it work.

Those are needed to establish a connection from the client to your server in order to push an update without a trigger from the user.

An totally different option is to reload the page (or perform an Ajax request) every x seconde or minutes to your server.

MThomas left a reply on Task Scheduling Runs Every Minute Despite My Directions

The idea is that the cron job is called every minute. And that you set the timeframe/interval on your jobs. If there is no job set in your code base for the moment the cronjob runs, no jobs will be executed. If there is a job set in the codebase for that moment, it will run.

Or have I completely missunderstood your problem?

MThomas left a reply on Differents Between Eloquent ORM And Query Builder?

They are linked. Eloquent lets you use models to query your database. The query builder is what is used under the hood in Eloquent. And you can use) to query your database directely and build upon eloquent queries.

https://laravel.com/docs/5.8/eloquent https://laravel.com/docs/5.8/queries

MThomas left a reply on Laravel 5.8 Does Not Use Sqlite For Testing

Did you install Laravel Telescope? If so, you need to be sure you have the line below in your phpunit.xml:

<env name="TELESCOPE_ENABLED" value="false" />

MThomas left a reply on Data Is Not Deleting In Laravel

Did you follow the component structure of:

<template>
    <a href="#" @click="deleteUser(user.id)">
    <i class="fa fa-trash red"></i>
        </a>
</template>

<script>
   export default {
        data() {
            return {
                
            }
        },

        methods: {
        deleteUser(id){
           Swal.fire({
                  title: 'Are you sure?',
                 text: "You won't be able to revert this!",
                 type: 'warning',
                 showCancelButton: true,
                 confirmButtonColor: '#3085d6',
                 cancelButtonColor: '#d33',
                 confirmButtonText: 'Yes, delete it!'
               }).then((result) => {

               //send request to the server

                 this.form.delete('api/user/'+id).then(()=>{
                     Swal.fire(
                       'Deleted!',
                       'Your file has been deleted.',
                       'success'
                        )
                  }).catch(()=>{
                      swal("Failed!", "There was something worng.", "warning");
                  });
                 
                })
         
         },
        }
        
        mounted() {
            console.log('Component mounted.')
        }
    }
</script>


MThomas left a reply on Logout In Laravel Not Working

What did you change? Did you do something with the authentication routes, did you change the logic in the auth scaffold? It must be there since your code seems very similar to the default code in app.blade.php

<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown">
                                    <a class="dropdown-item" href="{{ route('logout') }}"
                                       onclick="event.preventDefault();
                                                     document.getElementById('logout-form').submit();">
                                        {{ __('Logout') }}
                                    </a>

                                    <form id="logout-form" action="{{ route('logout') }}" method="POST" style="display: none;">
                                        @csrf
                                    </form>
                                </div>

MThomas left a reply on Bulk Delete Of Records Where SoftDeletes Is True

@MIKE_SA - would be great if you marked my reply as the answer :)

Makes it also clear to others that there is an answer :)

MThomas left a reply on Bulk Delete Of Records Where SoftDeletes Is True

You don't have to pas the delete in forceDelete, you are already in the context of the delete...

You could change the inside of your loop to chain the forceDelete method:

Post::where('id', $post)->forceDelete();

And assuming that $post is an single ID and $postsToDelete an array of ID's instead of the loop you could do:

Post::whereIn('id',$postsToDelete)->forceDelete();

MThomas left a reply on Getting Relation's Related Fields In Laravel Eloquent Model

use qty_prices() instead. You need the query builder for the with() method :)

MThomas left a reply on Laravel API Image Upload

Thats where the videos on laracast can help you alot, there are several video's on file uploads, among them this one: https://laracasts.com/series/whats-new-in-laravel-5-3/episodes/12

Also take a look at this series: https://laravelfromscratch.com that will help you a lot I think.

MThomas left a reply on Issue With Eloquent: API Resources - Conditional Relationships

@ME@BAYES-SHELTON.CO.UK - The docs for Route Model Binding are here: https://laravel.com/docs/5.8/routing#route-model-binding

What you could do to backtrack your problem is dd() your user. Does it always load the company? If so, you might have specified an default eager loading property: https://laravel.com/docs/5.8/eloquent-relationships#eager-loading

MThomas left a reply on Auth::logout() Not Working As Expected

Why not add Auth::logout() to your /dev route and redirect to the guest route afterwards?

MThomas left a reply on Laravel API Image Upload

Have you checked this part of the documentation: https://laravel.com/docs/5.8/filesystem#file-uploads

MThomas left a reply on Laravel Rtl

you can set the locale in /config/app/php.

And find (and copy) other translations for the default translated strings https://github.com/spatie/laravel-translatable

In /resources/lang/ you can add other translations according to laravels localization: https://laravel.com/docs/5.8/localization

MThomas left a reply on Laravel Rtl

I think you have to do this using your css and your layout file.

https://www.w3schools.com/cssref/pr_text_direction.asp

MThomas left a reply on Undefined Variable: _ENV Error

@deekshith can you backtrack when this error occurred? What did you change before?

I think I have seen a similar question on Laracast, in that case the error occurred after a composer pull http://git.... and he/she forgot to run a composer install :)

MThomas left a reply on I Can't Access Header In Controller Construct

@munazzil sorry your answer does not make sense, there is nothing wrong with $this->user = User::where('id', Auth::id())->first(); the only viable comment about that part would have been that $this->user = Auth::user(); would have had the same result and event more effective.

->first() will get you the first result if there will be more, as ID is a primary key there can only be one result, so using ->get() will let you endup with a collection with one item and you need to add a loop or pull the first.

So yeah, your answer does not make sense at all.

MThomas left a reply on HOW CAN I SAVE THE PREVIOUS/YESTERDAY BALANCE

That is just basic laravel. add an if statement that checks if data has been saved for that day :)

MThomas left a reply on How Do You Install A Vue.js Package Into Laravel?

You should start watching the first episodes of the series, that will help you understand how Vue works. You need more understanding in order to get this not just to work, but not fall in any more pits.

Your creating two Vue instances (the ones with the 'el' property in it). keep the one that is default in your laravel app.js, and expand it with the things you need to add for vodal.

Copy the css files from your node modules directory to your own resource/css (if you use laravel mix) or public/css directory (you are currently trying to import them from outside the public realm). And add the import statements to your css/app file.

MThomas left a reply on 404 Page Instead Of {METHOD} Not Supported For This Route

If you really want to change the error, you could change the error rendering method for the exception being thrown:

https://laravel.com/docs/5.8/errors#render-method

16 May
1 week ago

MThomas left a reply on 404 Page Instead Of {METHOD} Not Supported For This Route

ah I see what you don't like. A solution can be that you change the default error handling (and you should realize that the error pages shown in your local development environment are differently styled that those on production). That way you can change the appearance of your error pages on production.

MThomas left a reply on Switching Team Subscription

I think it would be best to contact Jeffrey directly (click the contact link a the bottom of the page).

MThomas left a reply on Displaying Errors With Login And Register On Same Page

If you really can't change the markup of the page. The only option is adding a general error message, iterating over the fields errors. I don't think there will be an easy other option.

MThomas left a reply on How Do You Install A Vue.js Package Into Laravel?

@connecteev I think it best that you watch this series: https://laracasts.com/series/learn-vue-2-step-by-step

This is basic stuff regarding vue.

Add the 'component' to your blade template file where you will use the modal:

<vodal :show="show" animation="rotate" @hide="show = false">
    <div>A vue modal with animations.</div>
</vodal>

Add this to your public.js file resources directory

import Vue from 'vue';
import Vodal from 'vodal';

Vue.component(Vodal.name, Vodal);

export default {
  name: 'app',
    
  data() {
    return {
      show: false
    }
  }
}

Add this to your template layout file (near the spot where you include your own css)

// include animation styles
@import "vodal/common.css";
@import "vodal/rotate.css";

MThomas left a reply on 404 Page Instead Of {METHOD} Not Supported For This Route

You won't be able to access a POST Route as a GET. If you want to be able to visit the page in a browser or make a GET request, you need to register a get route:

Route::get('/admin/user/list/ajax', '[email protected]');

That is also the reason you will get the Method not supported error, you don't have a matching rout in your routes file that supports that method.

If you want to be sure that you will get a 404 for the get route, register a route (can be a closure) that will handle the get request and present the visitor with a 404:

Route::get('/admin/user/list/ajax', function() {
    return abort(404);
});
15 May
1 week ago

MThomas left a reply on 404 Page Instead Of {METHOD} Not Supported For This Route

Can you show your routes file?

It sounds like the order of your routes might cause this. If you have for example first a route ‘products/{product}’ followed by a route ‘products/sale’ the router will try to resolve ‘sale’ as a product. If you first declare the specific sale route, this will not happen.

MThomas left a reply on Displaying Errors With Login And Register On Same Page

An other suggestion is hiding (with jQuery or Vue) the login form when clients are registring and vice versa. Show the login form by default, add a button "Or create an account" that hides the login form and shows the registration form.

Think this will even be more user friendly.

MThomas left a reply on 404 Page Instead Of {METHOD} Not Supported For This Route

you might want to check this part of the Laravel Docs: https://laravel.com/docs/5.8/errors#custom-http-error-pages

You can change/add error handling pages :)

MThomas left a reply on How To Follow The "How To Manage An Open Source Project" Series?

@ericlbc have you clicked on the link that @jlrdw provided... it just gives you exactly what you want... the project that is build in a previous series and is used fo the "how to manage an open source project" series...

If you don't have time to click a link, you might want to make up your mind, if you even want to manage an open source project...

MThomas left a reply on Laracasts Search

@jeffreyway I love the new search, but for the form is does not work as you expect. When I click discussions, type 'testing' and press enter, I either end up in a forum tread, not the forum search results, and there have been times I ended up in the lesson search as well.

Don't get me wrong, I like the new search a lot, but for the forum it just does not work as expected.

MThomas left a reply on What Does Double Colon :: Mean In View()?

Below you'll find the documentation. As @cronix explained it has to do with namespacing views for packages.

https://laravel.com/docs/5.8/packages#views

MThomas left a reply on HOW CAN I SAVE THE PREVIOUS/YESTERDAY BALANCE

Honestly if you need help with that, I think you need to reed the laravel documentation or watch http://laravelfromscratch.com here at laracast. But in order to help you on your way, you could do the following.

Create a migration and model for it

php artisan make:model Balance -m

The -m makes not only a model but also a table.

Next add the following to the balances migration

$table->unsignedBigInteger('balance');
$table->datetime('closed_at');

This will add two columns to your migration. You can omit the closed)at column and let the default created_at column function for this. But using a dedicated column lets you add the balance for a given day at any time.

Next run your migration

php artisan migrate

And add to your code *where you calculated today's balance

$balance = \App\Balance::create(['balance' => $todayClosedBalance, 'closed_at' => now()]);

MThomas left a reply on HOW CAN I SAVE THE PREVIOUS/YESTERDAY BALANCE

Ehm, not sure what you are looking for, but why not create a balances table/model and store the balance for each day there. For each day a new row in the table, added benefit is that you will have the history too.

14 May
1 week ago

MThomas left a reply on Auto Send Email

Does the cli php have a different php.ini with different configuration? Did you change something on the default setup?

MThomas left a reply on Laravel Middleware Only()

You can also specify it on a route group and let it cover all in the group.

MThomas left a reply on How Do You Install A Vue.js Package Into Laravel?

Did you import and register it in your app.js as specified in the Vodal read me?

MThomas left a reply on What's Wrong With This?

Why are you using a slash in one of the home view names?

MThomas left a reply on SQLSTATE[23000]: Integrity Constraint Violation: 1048 Column 'product_id' Cannot Be Null (SQL: Insert Into `category_product`

Take a look here: https://laracasts.com/lessons/file-uploads-101 so you will leverage Laravel in uploading the image.

And probably watch some more of the videos here at Laracasts, this might be a good start: https://laracasts.com/series/laravel-from-scratch-2018

MThomas left a reply on PHP Updating Images

Not sure if you think we are wizards, but it might be helpful if you show us some of your code and tell us what packages you are using...

MThomas left a reply on Laravel Telescope Not Working On A Fresh Install (wrong Path)

Is there a reason you don't use valet or homestead?

Now you will always struggle with the url, and your local dev env will be different from production (expecting you don't want to expose your root.

MThomas left a reply on Using FormRequest Safely

Why not use array_get()? Not exactly what you want, but it has the benefit of dot-notation and it keeps the integrity of the original request data that is entered by the user?

Not sure why you would like to change the behaviour :)

MThomas left a reply on Best Practice For Validation And Dry Principle

you could also use a FormRequest object. And validate the field in an asynchronous API call to the server. In this way you will have the exact same rules 'client side'.

MThomas left a reply on Load Relationship Error

please put your code in code blocks: https://help.github.com/articles/creating-and-highlighting-code-blocks/

This makes it readable for us :)

MThomas left a reply on Routes - Weird Behaviour

Try moving the rout to the top? Laravel probably tries to resolve 'import' as the {id}

12 May
1 week ago

MThomas left a reply on How To Use Standard Php Package In Laravel? I Try To Import It But It Can't Be Found?

Once you imported the method using the use statement at the top of your file, you don’t need to use the whole paths of your class, just do

$validator = new Validator;

Or add a slash before the path, otherwise it looks relative to your current namespace (this is the case within the class, not for the use statement)

$validator = new \JsonScheme\Validator;

Sorry for bad markup, am on my iPhone

MThomas left a reply on Where Can I Modify The Email Verification?

@PATRICKADVANCE - Instead of changing, just override the methods you need to change to fit your logic by placing them in the controller directly.

MThomas left a reply on Change ID-->Name In URL

What you are looking for is route model binding : https://laravel.com/docs/5.8/routing. This’s will also pull in your model directly

Don’t forget to register the route key, in your case ‘name’ in the model.

Next you exclude the show route

‘’’ Route::resource('photos', 'PhotoController')->except([ 'show' ]); ‘’’

And create a get route for your show method, and change $id to whatever you used in your route to specify your model.

MThomas left a reply on Something About Jeffery's Twitter

Jeffrey deletes his tweets regularly and that description jas been there a while.