MThomas

MThomas

Member Since 5 Years Ago

Eindhoven, The Netherlands

Experience Points
124,210
Total
Experience

790 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
940
Lessons
Completed
Best Reply Awards
61
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 25
124,210 XP
Oct
01
1 month ago
Activity icon

Replied to Laracasts Roadmap

@kristapseglitis If I may give you an other suggestion, filter down on the search page for 'beginner' and 'series' the recent series wil give you an excellent additional resource.

For example, the series on eloquent relationships will be a valuable addition to the series @tray2 mentioned :)

Aug
28
2 months ago
Activity icon

Replied to Laracast Post Time Issue

I remember informing @jeffreyway about this early on but it still has not changed. Guess something is wrong with the timezone offset calculations :)

Now I start wondering if there is also an time issue with the time estimate in scheduled videos.

Wondering when: https://laracasts.com/series/mysql-database-design/episodes/17 will get online. Here it states 35 minute from now (14:25 UTC+2 - Amsterdam).

Aug
26
2 months ago
Activity icon

Replied to How/Where Should I Code A Dropdown List

I think the best advice I can give you is start with a series like: https://laracasts.com/series/laravel-from-scratch-2018

Next move on to series like: https://laracasts.com/series/lets-build-a-forum-with-laravel or the more recent https://laracasts.com/series/build-a-laravel-app-with-tdd

Im fairly sure that these series will get you up to speed on how to use Laravel as it is designed.

Good luck!

Aug
15
3 months ago
Activity icon

Replied to Urgent Whoops

@pdc I wish you a long and happy life as a developer and kindly request you to stop bashing a framework without any substantial evidence :)

Good Day

Aug
14
3 months ago
Activity icon

Replied to Casts

Casts can be used to convert (cast) a JSON string to a native array, or a mysql boolean (tiny int) to a php boolean (true/false).

In order to prevent users from entering invalid data, you need to validate the users input.

https://laravel.com/docs/5.8/validation

On a side note, you never should store or handle phone numbers as integers, this will get you in trouble:

https://stackoverflow.com/questions/24353778/which-is-best-data-type-for-phone-number-in-mysql-and-what-should-java-type-mapp

And remember that php does not play nice with long integers

Aug
13
3 months ago
Activity icon

Replied to Urgent Whoops

@pdc why open a 2 year old post for these kinds of discussions...

If you so strongly believe that Laravel is an insecure framework, show some evidence, make security reports or issues on GitHub... in stead of complaining... nobody here forces you to use it.

On the topic of Whoops. By default Laravel will disable Whoops for production... you have to enable it manually in order to show on production.

Aug
07
3 months ago
Activity icon

Replied to Vue.js (Laravel + Vue) Not Working On IPhone.

Please elaborate on the issue...

What response do you get? Is it a Laravel issue? Have you tried turning on Debug Mode?

Jul
30
3 months ago
Activity icon

Replied to AssertSee Videos?

Great you got it to work!

As a rule of thumb, if you run into an issue, share the code your are working on, in this case the test method, the controller action etc :)

Good luck!

Activity icon

Replied to 401 Unauthenticated In Ajax Login...

If you want us to help you, show us the code you have written, what routes you have defined etc.

A 404 means that it can't find the requested url, so that might be a start in your debugging.

Activity icon

Replied to AssertSee Videos?

As far as I know you can assert the response contains a certain HTML string using assertSee().

https://laravel.com/docs/5.8/http-tests#assert-see

And please realize and accept(!) that you need to provide the forum with information, we don't know what you want etc, only in your last post you mentioned the use of YouTube and iframes, prior to that, it could have been an Laravel model etc...

Activity icon

Replied to Authentication In An SPA

What about https://laravel.com/docs/5.8/socialite

And if the default drivers don't cover your use case you can find many others here: https://socialiteproviders.netlify.com

And if you want to add your own OAuth server, take a look at https://laravel.com/docs/5.8/passport

Jul
24
3 months ago
Activity icon

Replied to Dynamically Create Subdomain

I guess, the best way to find out is to give it a try.

But as you need to record the subdomain somewhere there is no reason you could not redirect there (its nothing more than a regular redirect).

Activity icon

Replied to How Can I Use Pagination In Laravel Vuejs?

Just the two first google results for: laravel vue pagination:

In other words, what did you try, where did you get stuck?

Activity icon

Replied to Dynamically Create Subdomain

Sounds like a Multi tenant approach might help you. This will also enable you to isolate all tenant/company data in seperate databases or tables.

Take a look at https://laravel-tenancy.com/ or https://github.com/orchestral/tenanti for composer packages doing the heavy lifting.

If you like to do it yourself take a look at these two great blog posts:

Jul
21
3 months ago
Activity icon

Replied to Route [admin.categories.index] Not Defined.

You namespace and file path are connected :).

If it solved your issue, please mark it as the answer, that helps others.

Activity icon

Replied to Connection Could Not Be Established With Host Smtp.mailtrap.io [Connection Refused #111]

Two things, please tell us what you did, how does the code look that invoked the email.

Secondly you exposed you Mailtrap SMTP/API username and password, might best to remove them from the post and renew them on Mailtrap's side.

Activity icon

Replied to Route [admin.categories.index] Not Defined.

What is the path of your controller?

It should be in app/Http/Controller/Auth/Admin.

Activity icon

Replied to Route [admin.categories.index] Not Defined.

Within the route group you prefix all controllers with Auth/Admin and your CaregoriesController is just in App/Http/Controllers and not in App/Http/Controllers/Auth/Admin.

So if you want it to work move the file for the Admin directory and update the namespace accordingly.

Activity icon

Replied to Variable Not Passing To View

What url are you visiting? How dis you install Laravel? Are you using Homestead or Valet?

Jun
21
4 months ago
Activity icon

Replied to Conditional Filtering On Related Model

@andersb Not sure what you're asking. You said, that if there is a post, you would like to get all comments not just the comments of the post you're viewing, that is what that query does.. it only uses the timestamp of the post the user is viewing.

If the user is not viewing a post, but you just want comments that are a month old, Isn't that not just this:

$comments = Comment::whereDate('created_at', '>', now()->subMonth())->get();
Activity icon

Replied to Get Data From 3 Tables With Relationship Laravel

@ABDULBAZITH - As mentioned in my earlier comment. Assuming you have created the relationship on your order model. The comments shows you don't have the following relationship:

// In your order model
public function products()
{
    return $this->hasMany(Product::class);
}

// In your product model
// Or type is even better but then you need to update the eloquent query accordingly
public function product_type() 
{
    return $this->belongsTo(ProductType::class);
}

Jun
20
5 months ago
Activity icon

Replied to Conditional Filtering On Related Model

Not sure if I get it right, but isn't it as simple as:

$post = Post::find(123);

$comments = Comment::whereDate('created_at', '>', $post->created_at->addMonth());
Activity icon

Replied to Hoping For Pointers On CRUD Logging...

OK, I get your point. Can you explain why you want to do that? In the case you mention, you could easily resolve the Country's name based on its ID.

I'm not entirely sure why you want to log for example that piece of data. Just thinking out of the box and filling in some information. But in case you try to log: "MThomas (Netherlands) updated his profile", you could do something like this:

activity()
   ->performedOn($user)
   ->causedBy(auth()->user())
   ->withProperties(['country_id' => $user->country_id])
   ->log("{$user->name} ({$user->country->name}) updated his profile.");

If this is not the case, let me try a different idea (have not tested or tried this). Assuming there is not an endless list of fields from related models you'd like to log. Why not create an accessor attribute for the item you like to log, and add it to the luggable attributes:

use Illuminate\Database\Eloquent\Model;
use Spatie\Activitylog\Traits\LogsActivity;

class User extends Model
{
    use LogsActivity;

    protected $guarded = [*];
    
    protected static $logAttributes = ['name', 'country'];

    protected static $logOnlyDirty = true; // Only log created and changed fields

    public function country()
    {
        return $this->belongsTo(Country::class);
    }

    public function getCountryAttribute()
    {
        $this->country->name;
    }
}
Activity icon

Replied to Get Data From 3 Tables With Relationship Laravel

Why not use the GroupBy functionality of Eloquent, assuming your Order model has a product relationship and your Product model a product_type relationship.

Order::with(['product.product_type' => function($query){
        $query->groupBy('id');
    }])->get();
Jun
19
5 months ago
Activity icon

Replied to Hoping For Pointers On CRUD Logging...

The package will log all or a selection of fields for models (that have a certain trait and implementation) every time you create or update the model. So if you add the trait to all models you want to track, you should be fine.

Yes, you might log more that you need, but you could create a artisan job that deletes unnecessary logged items or something like it (if it is really a problem). Otherwise using a standard package that fits 80% of your need vs the downside of building and maintaining your own implementation might not weigh up.

Jun
17
5 months ago
Activity icon

Replied to Azure AD Authentication In My Laravel Web App

@lxg Most of the time there will be package for such a feature.

Good luck!

Activity icon

Replied to Azure AD Authentication In My Laravel Web App

Any reason you're not using on of the Azure AD packages? For example?

https://github.com/metrogistics/laravel-azure-ad-oauth -- Extension of Socialite https://github.com/rootinc/laravel-azure-middleware -- Based on middleware

Jun
12
5 months ago
Activity icon

Replied to Is There A Way To List All Relationships Of A Model?

@sonoma Why are you responding to posts that have been inactive for years...

Jun
07
5 months ago
Activity icon

Replied to Check If Model Has Changed Since First Save

Not build in (as far as I know). But I can highly recommend this package by Spatie:

https://github.com/spatie/laravel-activitylog

it enables you to track changes for specified attributes.

Activity icon

Replied to Open A Register Form Only In Sunday

@BELHEDI - Please mark it as the accepted Answer, this helps others identifying questions that have been answered :)

Activity icon

Replied to Open A Register Form Only In Sunday

Even more elegant is:

if(now()->->isSunday()) {
    return view('foo.bar');
}

You leverage Carbon and the Laravel helper which makes it even more expressive.

Jun
05
5 months ago
Activity icon

Replied to Select Inputs Ignored By Validation

Are you sure your request data includes the field?

Try a return $request->all() before validating to check it is in your request data.

If you want to include user input in your validated data array, you can add it without any rules:

'email' => 'required|email',
'data_not_validated' => '',

If you want to manually add something to a create method you could do this:

$data = $request->validate([
    //
    'email' => ['required', 'email'],
    //
]);

$data['foo'] = 'bar';

$model = Post::create($data);
Activity icon

Replied to Select Inputs Ignored By Validation

You could use ‘required|in:male,female’

https://laravel.com/docs/5.8/validation#rule-in

May
28
5 months ago
Activity icon

Replied to How To Install This IBAN Validator In LARAVEL

Why not use this package: https://github.com/Intervention/validation

This is tailormade for Laravel.

Activity icon

Replied to Role-based Multi-tenant With Tenant Subscription To Selected Features

Yes, the can directive can limit access to resources, and you can also scope queries down to the teams (could even add a global scope for this).

With regard to the subscriptions. You could add that functionality to the team model instead of the user model.

May
25
5 months ago
Activity icon

Replied to Role-based Multi-tenant With Tenant Subscription To Selected Features

You should take a look at https://github.com/spatie/laravel-permission this works great with Laravels permission system.

And as you said, combine it with Laravel cashier and you will have the most flexible integration you can wish for.

Just asign users roles and teams, and link permissions to roles and teams. You could use the Laravel's gate/authorization features to check the acces to a certain resource based on there presence in a team.

Activity icon

Replied to Thoughts On Subscribing To Laracasts?

If you are still in doubt, why not register for a monthly subscription and find out yourself. I found I extremely useful, and if you take a look around at the forum and the users badges, you will see there are very experienced developers and juniors here. For everyone there will be something useful.

Activity icon

Replied to How Can I Hide Or Remove Id From Url In Laravel?

Take a look at this package, will leverage a lot of work for you:

https://github.com/cviebrock/eloquent-sluggable

May
23
5 months ago
Activity icon

Replied to 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 () {
        //
    });
});
May
18
6 months ago
May
17
6 months ago
Activity icon

Replied to 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.

Activity icon

Replied to 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?

Activity icon

Replied to 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

Activity icon

Replied to 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" />

Somehow having telescope enabled while running tests causes an .env problem.

Activity icon

Replied to Data Is Not Deleting In Laravel

Did you use the Vue component structure and compiled it down?

<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>
Activity icon

Replied to 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>

Or try reverting back to the code above, the one that is provided in the default layout/app.blade.php file :)

Activity icon

Replied to Bulk Delete Of Records Where SoftDeletes Is True

@MIKE_SA - Glad I could be of help

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

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

Activity icon

Replied to 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();