Member Since 3 Years Ago


Developer at Manchester

Experience Points 157,700
Experience Level 32

2,300 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 1402
Best Reply Awards 24
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.

11 Sep
4 days ago

m7vm7v commented on At A Glance

Can we get a video lesson how you created the video @jeffreyway


03 Sep
1 week ago

m7vm7v commented on Explain PHP Generators

Thanks to generators there is huge memory usage improvement!

BUT also slower execution (which in my opinion it worth it)!

26 Aug
2 weeks ago

m7vm7v left a reply on Laravel Soft Cascading Deletes

https://laracasts.com/lessons/soft-deletions Its a bit old but still applies the concept.

m7vm7v left a reply on Simplify Code

You could do a lot of things. You can extract all of them in each classes, implementing an interface that could handle() the request. Or have a helper trait. Or just simply do something like -

    private function upload(Team $team, $teamFolderPath, $teamFileNameAttribute)
        $file_name       = Uuid::generate()->string;
        $filePathSociete = $teamFolderPath . '/' . $file_name . '.jpg';

        $team->$teamFileNameAttribute = $file_name;

        ImageUploading::dispatch(request()->$teamFileNameAttribute, $filePathSociete, $file_name);

    private function uploadGarantie(Team $team, $teamFolderPath)
        return $this->upload($team, $teamFolderPath, 'garantie_financiere');


It all depends on your setup but you have plenty of room for improvements.

Hope that helps.

m7vm7v left a reply on Info About Laracast

You could see that on the bottom of the page Designed with heart by Tuds https://twitter.com/tudssss

I think VueJs has been used for the front end with tailwindcss.

09 Feb
7 months ago

m7vm7v left a reply on Trying To Get Property Of Non-object In Riari Laravel Forum

I have not used this pack before so please ignore me if my answer is incorrect but you can try -

    {{ $thread->lastPost->author_id }}

m7vm7v left a reply on Better Way Of Getting Posts By Some Params

From both the examples the second approach looks better. Rather the !is_null($request->input('type')) you cane use $request->has('type') and inline the statements for some refactoring.

01 Feb
7 months ago

m7vm7v left a reply on One Auth For Multiple User

Hi, you can use https://github.com/spatie/laravel-permission so then you will be having single login interface and multi roles easily.

Have a look into this too https://www.qcode.in/easy-roles-and-permissions-in-laravel-5-4/

Hope that helps

m7vm7v left a reply on Queue Crash After Upgrading From 5.6 To 5.7

It looks like a known problem https://github.com/symfony/symfony/issues/20988

Have you tried executing sudo phpdismod opcache after so try restarting all the dependencies.

I hope that helps you.

m7vm7v left a reply on Constant Expression Contains Invalid Operations And Expression Is Not Allowed As Default Value Errors

You can use sometimes and when you validate if the email is the same then do not include it in the request https://laravel.com/docs/5.7/validation#conditionally-adding-rules

Or try with 'email' => 'required|string|max:255|email|unique:users,email,'.$this->id

30 Dec
8 months ago

m7vm7v left a reply on Laravel Check Nullable

If the object extends Model then you can call the ->exists() when you retrieve the object that returns true/false.

m7vm7v left a reply on Localization Series

+1 Nice suggestion @cryptopia I would love to see such a series.

m7vm7v left a reply on Return A Model With Dynamic Eager Loading

I would highly recommend you not to use the env() directly in your code -> better if you store this in your configuration files and use the config(). Other than that eager loading as you have found out comes with the ->with().

01 Dec
9 months ago

m7vm7v left a reply on Filling Fields On Input

Fair enough @bigstack2. You could write your relationship between City & Country so then-

public function yourMethodSendingDataToTheView()
    //some validation ...

    $city = City::whereName(request('searchinput'))->with('country')->firstOrFail();

    return view('your_view', [
        'data' => $someData,
        'city'  => $city->id,
        'country' => $city->country->id,

so then in your view you would be able to use the {{ $city }} and {{ $country }}

m7vm7v left a reply on Search Multiple Tables And Columns From Database

@ralphdns there might be someone else running into the same issue. Could you possibly write down what was your solution so this thread could be actually helpful.

m7vm7v left a reply on How To Make Default Auth Use Redis Queues?

You could rewrite/extend the ResetPasswordController adding the - reset(Request $request){...} and store your logic there extending it to use Queue just explore how the Trait is using the broker and the reset() method in trait ResetsPasswords

I hope that will help you the process.

m7vm7v left a reply on How Can I Add Watermark On Video

It depends what libraries are you using.

I would suggest to use some js library such as https://www.npmjs.com/package/videojs-watermark or https://github.com/xbgmsharp/videojs-watermark

Or simply edit the video with your watermark and use the video as it is.

m7vm7v left a reply on Filling Fields On Input

I might have misunderstood you question at first then. If you need to do some logic behind then just do it in your controller. The html form you have given I would assume is part of an view. Got to the method that calls that view (your controller) and then you could have something like -

public function yourMethodSendingDataToTheView()
    //some validation ...
    $city = City::find(request('city'));
    $country = Country::find(request('country'));

    $matching = false;

    if($city->name === request('searchinput')) {
        $matching = true;

    return view('your_view', [
        'data' => $someData,
        'city'  => $city,
        'country' => $country,
        'matching' => $matching,

then in your view you can extend the logic you need

30 Nov
9 months ago

m7vm7v left a reply on Filling Fields On Input

On the second attribute where you have null you can set a prefilled value such as {{ request('country') ?? null }}

m7vm7v left a reply on Validate JSON With FormRequests

You can create a custom validation rule https://laravel.com/docs/5.7/validation#custom-validation-rules

so then the in the rules() you can do something like -

    public function rules()
        return [
            'post' => ['required', 'json', new ValidateJsonPost], //or ValidatePostFromJson ...

then create it php artisan make:rule ValidateJsonPost

    public function passes($attribute, $value)
        //json decode the $value
    //then Validator::make($decodedJson, [
        'title' => 'required|min:5|max:100'

There are a few other ways but for me that looks the cleanest approach. Hope that helps.

19 Nov
9 months ago

m7vm7v left a reply on How To Show JSON Response When We Hit Logout Method In Api?

In your logout() method you could have an

if( auth()->guest() ) {
    return response()->json([
    'name' => 'Name',

m7vm7v left a reply on How To Display Specific Column Value In Collection Laravel

In your controller you could filter the collection

$seekers=User::orderBy('created_at','desc')->where('is_accepted', '=', '0')
->with(['education','language', 'certification','skillset','experience','career','project'])
->filter(function ($user) {
    return $user->education->course_or_board == 'PG';

or in your view you could have an if statement

@foreach($seeker->education as $edu)
    @if($edu->course_or_board == 'PG')
        {{ $edu->course_or_board}}

m7vm7v left a reply on Error When I Try To Use Json Translation File In My Package ?

Hi @cherrypulp

Try renaming the json file /resources/lang/en/myfile.php to /resources/lang/en.php and store the json code.

so then you could use the __('users'); or @lang('users') to retrieve it.

18 Nov
9 months ago

m7vm7v left a reply on Error When I Try To Use Json Translation File In My Package ?

I would recommend you using more of the dd(); helper.

If you do dd(__DIR__); it would easily stands out where you are currently at.

Anyway even if the official docs recommend you using the __DIR__ you could also try the resource_path('lang') - https://laravel.com/docs/5.7/helpers#paths

$this->loadTranslationsFrom(resource_path('lang'), 'mypackage');

Are you also registering it into your service provider's boot method as proposed in the documentation?

m7vm7v left a reply on Problem With Join Tables

I would recommend you to change of using Models + relationships.

It does not mean you are doing it wrong but would make your life easier.

In your User model you could have -

public function profile()
    return $this->hasOne(Profile::class);

public function clicks()
    return $this->hasManyThrough(Click::class, Profile::class);

public function impressions()
    return $this->hasManyThrough(Impression::class, Profile::class)

then in your controller

public function index()
    $data = auth()->user()->with(['profile', 'clicks', 'impressions']);

m7vm7v left a reply on Search Multiple Tables And Columns From Database

Hmm you have missed the name="location_id" parameter on the second <select> then in your [email protected] you would have the

    public function getIndex( Request $request ) {
        //validate the request 

    $demand_id = $request->input('demand_id');
    $location_id = $request->input('location_id');
        // Query and paginate result using the values from demand_id & location_id

    // return;

m7vm7v left a reply on Select In Blade

Try with

  <option value="1" {{ $bill->payment_id == 1 ? 'selected ' : ' ' }}>Rimessa diretta</option>
  <option value="2" {{ $bill->payment_id == 2 ? 'selected ' : ' ' }}>Bonifico Bancario</option>
  <option value="3" {{ $bill->payment_id == 3 ? 'selected ' : ' ' }}> PayPal </option>

m7vm7v left a reply on Laravel Helper Function

You could do in your Post model -

public function isArchived()
    return $this->archived == 1;

and in the blade you could have simply the

@foreach(auth()->user->posts as $post)
        //some logic for the archived posts
13 Nov
10 months ago

m7vm7v left a reply on Notify On New Connection From New Device

@dlebedef You can extend that table as much as you would like.

What I would suggest is to look after like two factor authentication, this one looks like a good one to help you with. Hope the link is not considered against the rules. https://scotch.io/tutorials/how-to-add-googles-two-factor-authentication-to-laravel

12 Nov
10 months ago

m7vm7v left a reply on Notify On New Connection From New Device

@dlebedef so then you could easily create a new table with trusted_devices and a pivot table between the records and the users so then the user could have a hasMany relationship with the trusted_devices so then in the middleware you could check against this table.

m7vm7v left a reply on Implementing Laravel Redis, Echo And Vue.js For Real Time Update

Could you possibly give us some code that we can amend so we can help you with your issue.

You would really benefit of watching these series https://laracasts.com/series/get-real-with-laravel-echo

m7vm7v left a reply on Laravel 5.7 Email Verification

In my opinion the middleware approach is the ideal in this case.

Like Jeffrey says - think that the middleware is like and onion layer. The email verification is a protection that would be the best to be handled trough that onion so the request would continue or stop execution early rather than hitting controller or a policy - which is not incorrect but would make more sense that can be handled in the request level by the middleware.

m7vm7v left a reply on Notify On New Connection From New Device

I had to do something similar before. What I did then was creating a new middleware that is checking the logged user's fields ("browser", "platform" and "device") and check them against the current request.

If is something else then update the user's data and flash the message (or additional action) and return the $next object as usual. Do not forget to register the new middleware to be executed on all requests.

Hope that helps you.

m7vm7v left a reply on How To Customize Delete Functionality On Nova?

You could define a new Action.

php artisan nova:action DeleteModel so then in the handle method you could add the delete action

public function handle(ActionFields $fields, Collection $models)
    foreach($models as $model){
        //Your custom logic before delete
        $model->delete(); //->softDelete()

        //if the deletion fails then return a Action::danger('Message');

    return Action::message('Deleted!');

In the nova Model add the new DeleteModel action in the actions() method.

Do not forget to remove the delete button from the default actions.

so then if you need for this action some additional information you could add this in the fields() method in the DeleteModel.

Have a look at this video - https://laracasts.com/series/laravel-nova-mastery/episodes/10

m7vm7v left a reply on Validation Auth And Functional Test In One Method?

It is a personal preferences in the end of the day.

What I would do is following what Jeffrey has shown us in the TDD lessons. I would separate the test into smaller more easily understandable-readable tests. For example if I have 2 fields that need validation I would create 2 tests for each a_post_requires_a_title so after once tested this then in the an_authenticated_user_can_create_new_forum_post you do will just send a validation friendly data as you already know it is fine.

Smaller test - better readability, easier to understand if you go again in 6 months fo a change or someone else picks it, and then if a functionality is changed then only the small piece of test would be amended rather than going trough the big test - for example later on the client decides that the title is not only required as you have tested in a_post_requires_a_title but also it needs atleast 20 chars - then you would go to the 'big' test and amend it rather than just creating additional small test for the or amending the a_post_requires_a_title with a better title of course.

When you separate the big test into smaller then you will find out that all the comments you have placed could be actually removed entirely as that will be explained in the test name itself.

In addition try creating some helper functions.

Hope that helps.

m7vm7v left a reply on Policies/Gates For Custom Things?

You could easily do that inside your LessonPolicy -

public function seeInvoiceWithFailedChargingAction(User $user, Lesson $lesson)
    if ( lesson has invoice, and invoice was attempted to be charged but failed) { 
        return true;

    return false;

Then you can use @can('seeInvoiceWithFailedChargingAction', $lesson)

Hope that helps and guide you in the right direction.

09 Nov
10 months ago

m7vm7v left a reply on How Do I Test Login Throttling?

What I would do is for example if you have throttled for 5 times then

//create a user with known password 
$user = factory(User::class, ['email' => '[email protected]', 'password' => 'secret']);

//then make 5 post request to the authentication route
for ($i = 0; $i < 5; ++$i) {
        $this->post(route('admin.authenticate'), [
            'email' => $user->email,
            'password' => 'wrong',


//then on the 6th you would expect to see the throtteler to stop the request
$this->post(route('admin.authenticate'), [
            'email' => $user->email,
            'password' => 'wrong',


I would also recommend you to watch this https://laracasts.com/series/whats-new-in-laravel-5-5/episodes/17 and use the $this->whithoutExceptionHandling();

m7vm7v started a new conversation Looking For The PHPStorm Selection Keybinding

What is the default keybinding for selecting a higher instance on Mac? For example if I have the line someFunction($array = ['something' => 'else']) and my pointer is on the word else when I press this combination I expect the 'else' to be selected if I press it again ['something' => 'else'] will be, if once again then $array = ['something' => 'else'] and so on.

20 Oct
10 months ago

m7vm7v left a reply on Role Question - Shall I Set The Access In Router Or Controller Or Both?

The same as before - just stick with a convention you would like to use and maintain it.

What here in Laracast has been advised is to try as best as you can to stick with 1 'resource' controller with all the methods and if you need to extend some functionality then create a new one with the logic for it. For example getImages() getSmallerImages() getBiggestImages() getBlackAndWhiteImages() could easily be in a new controller 'ImagesController' with index(){ $image->bySize('big')} and create some logic behind for a big/small images in the Model. I would have 1 controller instead of the 4 you have given as an example and rely on get parameters site.dev/posts/1/images?size=big&blackAndWhite=true then the controller could validate, authorise, get data and return as json/view - but getting the data I would store in the Model itself.

Hope that makes sense.

17 Oct
10 months ago

m7vm7v left a reply on Role Question - Shall I Set The Access In Router Or Controller Or Both?

The simple answer would be - Yes, the route middleware would be enough.

But consider the situation when you need both. What if in the middleware you specify that admin and moderator can visit the controller's method but in the controller you could make a different logic depending who is visiting.

public function viewIndex(){ 

        return view('view_with_administration_panel_and_moderator_panel')

        return view('view_with_moderator_panel_only')

What I would advice you is to use whatever makes more sense to you.

I would use Policies and authorisation rather than route middleware or a bunch of if_else statements in the controller. In the controller you would just simply have $this->authorize('view', $post); OR route ->middleware('can:view,App\Post'); Have a good look at https://laravel.com/docs/5.7/authorization#writing-policies Hope that helps you.

29 Sep
11 months ago

m7vm7v left a reply on Help BelongsToMany And HasMany

Not sure is it that what you are asking for but have you tried the hasManyTrough relationship - https://laravel.com/docs/5.7/eloquent-relationships#has-many-through

    public function items()
        return $this->hasManyThrough('App\Item', 'App\Home');

I hope that will help you.

m7vm7v left a reply on Allowed Memory Size Of 134217728 Bytes Exhausted (tried To Allocate 65015808 Bytes)

You can try this one to guide you of what you need -

        $adModels = RevAdvertisement::select('id', 'type', 'link', 'banner', 'country', 'city', 'post_code')
            ->where('user_id', '<>', $userId)
            ->where(['status' => 1, 'payment_status' => 1]);


        $adModels = $adModels->get()->map(function ($adModel) {
            if($adModel->type == 'Youtube'){
                $adModel->link = $adModel->link . '?autoplay=1&origin=https://www.xyz.vip';

            return $adModel;

23 Sep
11 months ago

m7vm7v left a reply on Error: Call To Undefined Method App\User::users() -- Trying To Differentiate Users

You better try using Policies. Its really easy and makes a lot more sense at then and of the day.

for the isAdmin() method I would suggest is to change it for the current user, as the logic follows this, buts its all up to you

public function isAdmin()
            if ($this->role == 1)
                return true;

        return false;

what you are trying here is most likely to be called differently -

public static function getAdmins()
    return self::where('role', 1)->get();

in the blade I would suggest to make a second check

@if (auth()->check() && auth()->user()->isAdmin())

Hope that all makes sense.

20 Sep
11 months ago

m7vm7v left a reply on Should Caching Be Done Within A Repository?

You can extract the caching on a different level. What I can suggest you is creating an interface ForumRepositoryInterface which will implement the methods that any repo should have -

interface ForumRepositoryInterface {
    public function getAll();

    public function store();


Then create your repository - DbForumRepository

class DbForumRepository implements ForumRepositoryInterface {

    public function getAll()
        return Forum::all();

    public function store()
        return Forum::create([
            'title'   => request()->title,
            'body'    => request()->body,
            'user_id' => auth()->id(),

Then the caching -

use Illuminate\Contracts\Cache\Repository as Cache;

class CachingForumRepository implements ForumRepositoryInterface {

    private $cache;

    private $repository;

    public function __construct(ForumRepositoryInterface $repository, Cache $cache)
        $this->repository = $repository;
        $this->cache = $cache;

    public function getAll()
        return \Cache::rememberForever('forum', function (){
            return $this->repository->getAll();

    public function store()
        $forum = $this->repository->store();


        return $forum;

Then go to your AppServiceProvider to register them -

public function register()
        app()->singleton(ForumRepositoryInterface::class, function () {
            $dbRepo = new DbForumRepository();

            return new CachingForumRepository($dbRepo, app('cache.store'));

I hope that makes sense and helps you to understand the principles.

m7vm7v left a reply on Creating Brand Categories

You need to make a few tweaks

public function index(Channel $channel)
        if ($channel->exists) {
            $brands = $channel->brands()->latest();
        } else {
            $brands = Brand::latest();

        return view('brands.index', ['brands' => $brands->paginate(15)]);

And in you view -

<div class="container">
    @foreach ($brands as $brand)
        @if($brand->channel_id == 1)
        //do something
        @if($brand->channel_id == 2)
        //do something

{{ $brands->links() }}

Have a good read at https://laravel.com/docs/5.7/pagination

16 Sep
11 months ago

m7vm7v left a reply on Missing

Hi @fam , if you think that is the answer that helped you the most to solve the problem could you possibly click the 'tick' under the avatar as it could help someone else who has run into the same issue?

m7vm7v left a reply on Failed To Load Css And Js Files

Is it the case you are migrating to a different OS? What was the OS on the PC and whats on the laptop? If you could use a vagrant/docker box would suit you the best in such a cases.

m7vm7v left a reply on REST Authentication

Hi, I would recommend you to use Laravel Passport - it is what you need for this task. Just follow the official instruction as they are clear enough - https://laravel.com/docs/5.7/passport

m7vm7v left a reply on Best Way To Authorize

I would say that the using Policies would be a good option and the best place I would store would be in the beginning of the controller's method. I think that would give you the best flexibility and in the end of the day you can use 'can()' in the blades and will give a good control in place.