Member Since 2 Years Ago

Experience Points 20,520
Experience Level 5

4,480 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 168
Best Reply Awards 5
Best Reply
  • 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


    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement


    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.

10 May
1 week ago

mironmg left a reply on Finding Out If A Table Is Empty

empty is for collections. You are checking a address that hasn't been stored in the database yet. And if you store it, it's an eloquent model, not a collection. Try something like this

public function addPostAddress(Request $request)

        $user_id = Auth::user()->id;

        $address = new Address();

        $address->user_id = Auth::user()->id;
    $all_addresses = Address::all(); //get all addresses from the db table

        if(!empty($all_addresses )) //check if it's empty
            echo "not empty";
            echo "empty";

        return redirect()->back();
27 Apr
3 weeks ago

mironmg left a reply on Method App\Http\Requests\ProductRequest::categories Does Not Exist.

@IRANKHOSRAVI - First of all, you should learn some manners. People take some minutes from their time to help you. You can't demand answers. Second.. you are trying to associate a request with some categories. Which does not make any sense. Like @snapey said, you need to remove that line but you need to replace it with something else. You just created another problem... I'm assuming you want to associate categories with the product.

mironmg started a new conversation Javascript Class Constructor Fail

Hi guys

I have a js class called Property that I am using in my vue templates and a constructor Basically when I load a page, I make an ajax request to server, get the info for that model, assign it to a js object that I am using aftewards in my webapp.

So this object has a constructor class. Everything works fine except for one field which is listing_type This value assigns false, always. If I force assign it to a random string it works. If I console.log the variable it works. but when I assign the variable it does not. any ideas? Example below

class Property {
    constructor(db_property) {
        for(let field in db_property){
            this[field] = db_property[field];
        //everything works fine but when field == listing_type it just assigns false instead of the string
23 Apr
3 weeks ago

mironmg left a reply on How Much Of Code Syntax You Guys Remember?

It's normal and natural... especially when you're working with multiple libraries/frameworks. As you spend more time with one framework ( eg Laravel ) you're gonna remember syntax easier for it but perhaps you're gonna have trouble remembering some "js" stuff. I still mess-up simple things like "else if" and "elseif" when I write both front-end and backend on the same project. Like @ftiersch said, don't worry about it. we're only humans after all

16 Apr
1 month ago

mironmg left a reply on Error Using Composer To Install Bogardo/Mailgun And Php-http/guzzle6-adapter

Seems to me that nexmo needs versions 1.0 and 1.1 of php-http/guzzle6-adapter and you are trying to install version 2.0 Try installing a 1.1 version and see whether that works with your other packages

12 Apr
1 month ago

mironmg left a reply on Treeview With ---

Relationship is differnet from schema. you already have the "parent_id" field for creating the relationship. Please refer to https://laravel.com/docs/5.8/eloquent-relationships and watch some "laravel from scratch" tutorials. May take some time now but it earns you a lot of time on the long run

mironmg left a reply on Treeview With ---

You need a relationship between category and subcategory Then get all categories with their subcats


and in view file iterate through everything

    @foreach($categories as $cat)
    <option>{{ $cat->name }} </option>
            @foreach($cat->subcategories as $sc)
                <option>{{ $sc->name }} </option>

mironmg left a reply on Get All Through Pivot Table

in Plan.php you need to have a relationship

public function users()
    return $this->belongsToMany(User::class, 'subscriptions'); //second parameter is name of the subscriptions table

Then in plan model you can just call the ->users() method

10 Apr
1 month ago

mironmg left a reply on How/where To Adapt Email Verification?

@GEERIZZLE - You can track down the listener for Registered event and see what it does, then replicate that in a controller by yourself and do it whenever you want

09 Apr
1 month ago

mironmg started a new conversation Good RAM VPS

Hi guys. I am looking for an alternative to OVH CloudRam VPS on the market but I can't seem to find anything close to those prices. I really like OVH but although the specs are rather good, I've seen on several tests that their connectivity is not that great. For some instances they have response times over 2x higher than digitalocean. What VPS providers are you using?

mironmg left a reply on How/where To Adapt Email Verification?

You need to edit the Registered event that is being triggered by the register()method within RegistersUsers trait file. Basically you can extract the register method in the RegistrationController and comment out that event.

08 Apr
1 month ago

mironmg left a reply on My Server Is Not Loading The Latest Files.

maybe you had some compiled view files... try running view:clear as well when you clear the cache. This would most likely fix it

05 Apr
1 month ago

mironmg left a reply on Send Email With Event/Listener, Or Job?

Event/Listener. User submits a post -> event has happened (postSubmitted) -> listener sends email

mironmg left a reply on Make Sure To Provide The "name" Option.

@HJORTUR17 - Did you try to import the replies component in the app.js file and it failed? It should work if you do it like that

mironmg left a reply on Cannot Use A Scalar Value As An Array

@VANDAN - Like @ftiersch mentioned above, the approach is completely messed-up. You have to get a better grasp of what DB::table('table')->update() does. You can't use it in a loop. Also, you don't need to use DB where you can use eloquent...otherwise you're not taking advantage of laravel's features. I have explained in your other post how this should have been achieved.

mironmg left a reply on Array To String Conversion

@vandan You can't just post your error and code in here and wait for people to build your project. Try learning something..try explaining what you wanna achieve. You have to appreciate replies and understand that people who reply here are taking a piece of their time to help..make their "task" easier...

$all_imports = Import::all();

foreach($all_imports as $import){
    $half = $import->Amount_Grand_Total / 2;
    $import->update(['Half_Amount' => $half]);

return Import::pluck('Half_Amount')->all();

mironmg left a reply on Cannot Use A Scalar Value As An Array

I just tried to redo your code but then I realized I have no idea what you're trying to achieve... We need more info..maybe post the whole method ?

mironmg left a reply on Make Sure To Provide The "name" Option.

I may be wrong here cause I usually don't use the templates in-line but don't you wanna declare the replies component inside the app.js file? Basically you're not using the component in the Thread file, you're using it in the master layout, which means it does not make much sense to import it in that file...

mironmg left a reply on Re-use Section Code $.ajax With Jquery Validator

I hope I didn't mistunderstood this but can't you just have a method parameter? something like

$.validator.setDefaults( {
    submitHandler: function () {
            // method: "POST", 
            method: methodType, // where methodType is either 'PUT' or 'POST' and declared outside the function? 
            url: urlAction,
            data: $("#myform").serialize()
            .done(function(data, textStatus, jqXHR){
            .fail(function( jqXHR, textStatus, errorThrown){
} );

mironmg left a reply on Insert Or Update With Increments

@TIMGAVIN - You can default clicks to (1). Once you create the database entry it's already been visited once so it makes more sense.

04 Apr
1 month ago

mironmg left a reply on Insert Or Update With Increments

$search = Search::updateOrCreate(['term' => $request->username]);
$search->increment('clicks', 1);

Also I would extract this into the Search.php model file

public static function incrementOrCreateSearchTerm(Request $request)
    $term= self::updateOrCreate(['term' => $request->username]);
    $term->increment('clicks', 1);

and in controller just do something like


mironmg left a reply on Laravel, Vue.js And Checkboxes: How To Check Only One?

Did you consider that maybe you don't need to run vue just for a checkbox? If you still want to stick to your idea, you should use v-model and v-if.

There are weeks of tutorials on this website. Subscribe and give them a shot.

mironmg left a reply on Prevent Laravel From Removing Trailing Zeros

You need to change the database field to float. MySQL is "removing" it not laravel.

01 Apr
1 month ago

mironmg left a reply on Returning String Data From A Relationship Only

Hi there

I suggest spending a bit more time on naming relationships. In the extension's model file add a method like this

public function getTypePathAttribute()
    return $this->hasType->path // This relationship should be renamed to ->type instead of ->hasType.

and then use it in code like this


If you think you're gonna use it a lot in your code you can append it to the model using $appends https://laravel.com/docs/5.8/eloquent-serialization

protected $appends = ['type_path'];

mironmg left a reply on Updating Multiple Many To Many Relationships

why not using the DB facade? May be easier.

mironmg left a reply on Array Sum

if the collections have the same Class(model) instance you can use eloquent's sum() method

$items = Stock::where('foo','bar')->get();
$total_kg = $items->sum('kg');

mironmg left a reply on How To Catch A "Trying To Get Property Of Non-object Error" In Laravel

@ZASTER - Maybe try something like

$po_item = Item::where('foo','bar')->firstOrFail();
// It returns a 404 automatically if there's no item

If you don't want a 404 try something like

foreach($po_items as $item){
    // do what you want with the vendor & vat_no.

A third option would be to query only the items that have a vendor company, assuming that there is a relationship involved in there. and judging by the code, there is.

$items = Item::whereHas('vendor_company')->with('vendor_company')->get();
//gathers all items that have a vendor company attached and also loads the vendor company in the results so you don't stress the database after that to load it with each iteration 
03 Mar
2 months ago

mironmg left a reply on Cannot Save Avg Using UpdateOrCreate Method.

I think the problem is here

$rateUser = DB::table('rating')
                ->where('user_id', $id)

When you're getting the average you don't get a collection but a number. so first() doesn't make much sense. Also, you have some other issues in the code. By using updateOrCreate, you're assuming that the user may not exist in the database.. and you're trying to update their ID... that shouldn't be a fillable field.

$rate = new Rating();
        $rate->user_id = $id; // if the user_id may be non-existent this would end-up in an error.
        $rate->rating = $request->rating;

maybe try something like this

 public function changeRate(Request $request, $id){
    $user = User::find($id);
        return abort(403);

    $rate = new Rating();
    $rate->user_id = $user->id;
    $rate->rating = $request->rating;

    $userRating = DB::table('rating')->where('user_id', $user->id)->avg('rating');
    $user->update(['rate' => $userRating]);

    return $user;
28 Feb
2 months ago

mironmg left a reply on Collapsable Sidebar

And how can we help?

mironmg left a reply on How To Insert Multiple Records In Child Table

@akmahato ... Can you show us how $request looks like? I'm assuming the $request->input('sc_name') is an array ? If yes you should do something like this

for($i=0; $i<$n; $i++){
        'sc_name' => $sc_name[$i],
        'sc_desc' => $sc_desc[$i],
        'cat_id' => $category->id 

Also, You need to rename your category and subcategory models...why are they called AddCategory? They should be just Category and SubCategory.. it's very confusing.

mironmg left a reply on "Argument 1 Passed To Illuminate\Database\Grammar::parameterize() Must Be Of The Type Array, Null Given, Called In E:\LaravelProject\metrofeedback_v1\vendor\laravel\framework\src\Illuminate\Database\Query\Grammars\Grammar.php On Line 853

So...there's some things wrong in there.

public function store(Request $request)
        $input = $request->all();

        $category = new AddCategory();
        $category->c_date = $input['c_date'];
        $category->c_name = $input['c_name'];
        $category->c_desc = $input['c_desc'];
    // at this point you don't have a $category stored in the database. You just have an AddCategory model in memory, ready to be saved.

        $subcategory = new AddSubCategory();
        $subcategory->sc_name = $input['sc_name'];
        $subcategory->sc_desc = $input['sc_desc'];
        $subcategory->cat_id = $category->id; // here it is trying to get a non existent property of an object ( $category, not being saved, does not have an ID field yet). Hence it returns null. 
        $category->save($request->all()); // why? It should be just $category->save() and it should be before you declare a subcategory
        $category->subCategory()->save($subcategory); // this is wrong too. If you do this you don't need a "cat_id" field 

So try it like this

public function store(Request $request)
        $input = $request->all();

        $category = new AddCategory();
        $category->c_date = $input['c_date'];
        $category->c_name = $input['c_name'];
        $category->c_desc = $input['c_desc'];

        $subcategory = new AddSubCategory();
        $subcategory->sc_name = $input['sc_name'];
        $subcategory->sc_desc = $input['sc_desc'];
        $subcategory->cat_id = $category->id;
16 Dec
5 months ago

mironmg left a reply on Check If The User Own The File Before Show It

Do you store the image paths in the database? If not, maybe you should consider storing them under a /images/USER_ID/ folder. And check whether the user_id from the path matches the auth()->user()->id

Otherwise, if the images are stored in the DB and there's a relationship between the image & user, add a policy.

mironmg left a reply on Submitting Post Request From Vue Throwing MethodNotAllowedException

Check web.php (route file) and confirm whether /login is in fact a "post" route. That message is usually displayed when you're using the wrong method. (eg. "POST" instead of "PUT")

17 Jul
10 months ago

mironmg left a reply on Custom Artisan Command

@36864, it doesn't even dump anything if I put a test dump the first line within handle()...

16 Jul
10 months ago

mironmg left a reply on Custom Artisan Command

I've checked all the logs. No errors..

mironmg left a reply on Custom Artisan Command

Yep it returns a 0 but the Log::info() within the function are still not logged into the laravel.log file.

>>> Artisan::call(App\Console\Commands\SendDailyFollowupEmails::class)
=> 0

mironmg left a reply on Custom Artisan Command

@36864 Yep I did. And yes it does work on dev env. also tried to clear the cache, artisan down/up, aritsan clear-compiled ...

mironmg started a new conversation Custom Artisan Command

Hi guys... I have a small issue which made me pull my hair today so although I'm pretty sure it's just a basic thing I'm missing, I simply can't find it. I have a custom artisan command. It's registered, listed in artisan:list, works on localhost. Once I run it on production server it doesn't show any errors but it doesn't process any of the handle() function either because I have some Log::info() events in there to keep track of the actions and nothing shows up in laravel.log file. Anyone who had this issue before? Any idea what could it be? Other artisan commands are working ok on production server. Thanks

23 Jun
10 months ago

mironmg left a reply on Phone Number " UNIQUE " For Validation

I assume you're using validation when you get the data. https://laravel.com/docs/5.6/validation give this a good read...it helps a lot on long-term. Eg:

public function store(Request $request)
    $validatedData = $request->validate([
        'phone' => 'required|unique:users'

17 May
1 year ago

mironmg left a reply on Which Laptop To Buy?

If you're not an apple fan just go with a windows laptop. Of course macbook owners will tell you the quality is good, the keyboard is awesome etc... Just think practical and bare in mind that most of the high-end windows laptops have a very good build quality and they're less expensive than macbooks these days, compared to 5 yrs ago when apple was more than just a brand. Since you're programming, you don`t need a 4k monitor, you don't need an awesome graphic card, some could argue that you're not even gonna use the laptop's keyboard either because you're gonna have a second monitor and a separate keyboard if you have a nice office setup. So these being said the offer is sooo much wider when it comes to windows devices...you have lenovo,asus,dell,hp. You can find an aluminium laptop with SSD+HDD, i7-8550u, 16GB of ram under $1200. The resell value probably would not be the same as for an apple but you could use a device like this for 3 yrs without feeling the need to change it. So assuming you're wasting 300$ in resell value compared to a macbook, how much money do you actually lose overall considering the macbook prices start at over $2.3k ?

20 Apr
1 year ago

mironmg left a reply on Routes Issue

Hi guys... Probably I was misunderstood, the problem is not in the way I name the slug in the routes file but that the actual slug variable has a dash in its name, hence if I add another dash as a suffix, it messes-up. (eg sua-users works while north-korea-users won't work)

In case someone else bumps into this issue I ended up finding a solution which is not very clean but does the job without having to re-write a lot of view files.

I created a new RouteHelpers.php file where I declared a global function which accepts 2 parameters : route name declared in routes file and the slug ( similar to laravel's route() helper)

function buildCountryFiltersUsersRoute($routeName, $routeSlug)
    $countryRoutesThatNeedAppendedWords = [
        'countryUsers' => '-users',
        'underageCountryUsers' => '-underage-users',
        'activeCountryUsers' => '-active-users',
    if (array_key_exists($routeName, $countryRoutesThatNeedAppendedWords)) {
        return route($routeName, $routeSlug . $countryRoutesThatNeedAppendedWords[$routeName]);

    return route($routeName, $routeSlug);

then wherever I need to reference something like the below in views

route('underageCountryUsers', 'south-africa')

I replace it with

buildCountryFiltersUsersRoute('underageCountryUsers', 'south-africa')

Lastly, the Controller functions associated with those routes need an rtrim($slug, '-whatever_string_was_added')

Also the file has to be included within composer's autoload config.

Thanks to all of you for all replies.

19 Apr
1 year ago

mironmg left a reply on Routes Issue

@V9द, Thanks but this won't work, as I suggested in the initial question. It complicates things even more because the actual project uses a more complex setup than the example presented, with countries and users.

mironmg left a reply on Routes Issue

Nope, they think it's bad for SEO because they would have to create a page for users-by-country/south-africa as well and that would basically be a duplicate of the page I'm struggling with

mironmg started a new conversation Routes Issue

Hi guys. I'm having some issues with the routing... The clients want an extra string added after the slug like below

Route::get('/users-by-country/{country-slug}-users', '[email protected]');

There's no issue if the country has a single word in it and the slug does not contain a "-" character. But if the country slug is something like "south-africa", the url becomes "south-africa-users" and the page returns a 404.

Any idea of a workaround ? Changing slugs in the database is not an option...neither is composing the slug in view-files and removing the "-users" bit in Controller.

Thanks a lot!

10 Mar
1 year ago

mironmg left a reply on How To Solve This If And Else Statements Are Not Working In Jquery

@Kistlak I'm afraid I can't help without more info. But it seems to me that you're in a loop when you just try to patch things instead of actually debugging. check laravel logs, dump the data, look for errors

mironmg left a reply on How To Solve This If And Else Statements Are Not Working In Jquery

@Kistlak Just try and console.log the data youre getting from the server when you validate ( first request). the 'data' variable might be an object so you may wanna have to compare to 0 a property of data likeif(data.response != 0)`

mironmg left a reply on How To Solve This If And Else Statements Are Not Working In Jquery

@Kistlak I'm sure it's not related to jquery but to the validation you are doing on server's end. Don't rush into it. Think if you can improve that code.

$items = $request->input('items'); 
$items = str_replace(['[', ']', '"'], '', $items);
$user->item = $items

What is this for example? Wouldnt it be easier to have a belongsToMany relationship between the User model and let's say a Seat model? Then using the array that comes from the server like$user->seats()->attach($request->input('items'))? Also is there an event in there? Like a movie? Because the user may wanna buy seats for another event as well so youre overwriting the 'items' attribute if it does.

Regarding jQuery, why not just use a simple post request and validate data on server? If validation fails, return an error message.

mironmg left a reply on How To Solve This If And Else Statements Are Not Working In Jquery

You may want to do a console.log of your data variable retrieved here

if(data !== '0')
    $('#availability').html('<span class="text-danger">Seats not available</span>');
        $('#btnShowNew').attr("disabled", true);

This seems to be the $results variable from seatprocess() function. And there are a few things wrong in that function:

  1. use a 'return' instead of 'echo'
  2. make sure you understand what 'get()' method does. it returns a collection, you are checking the "if" statement against a string.

Try something likethis:

public function seatprocess(Request $request)
    $date = $request->input('date');
    $st = $request->input('st');
    $items = $request->input('items');     
    $results_number = DB::table('seats')->where(['date' => $date, 'st' => $st, 'item' => $items])->count();

    return $results_number;

and in your view replace

if(data !== '0') 
if(data != 0)

mironmg left a reply on How To Pass Logged In User Data To View From LoginController

You are trying to access a variable, try using a global

    Hi {{auth()->user()->name}}
    // or
    Hi {{Auth::user()->name}}