nhayder

Member Since 3 Years Ago

Doha

Experience Points
53,330
Total
Experience

1,670 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
379
Lessons
Completed
Best Reply Awards
2
Best Reply
Awards
  • start your 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-in-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 Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist 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.

  • Community Pillar

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

Level 11
53,330 XP
Jun
06
6 days ago
Activity icon

Replied to Trouble When Updating ManyToMany Pivot Table With Multiple Values

@silencebringer thank you for your replay, I'm not sure how to implement your solution? so I'm expanding on my case to give you further knowledge hoping we can solve this issue together.

on my update from I'm submitting data to update function on my order controller like this

// this is the request from update form 
{
_token: "rM8J9mjqy5LdUiyhRUzyR3DyZPqkACZkVTu3wqqr",
_method: "PUT",
		completion_date: [ // every tracking stage have completion_date
			"2021-06-08T10:58",
			"2021-06-15T18:03",
			"2021-06-30T18:04",
],
	tracking: [ // these are the id's of enabled tracking stages
		"1",
		"2",
		"3",
	],
}

so basically I have tracking[] + completion_date[] objects to update the pivot table

// this is my pivot table structure
Schema::create('order_tracking', function (Blueprint $table) {

            $table->unsignedBigInteger('order_id');
            $table->unsignedBigInteger('tracking_id');

            $table->foreign('order_id')->references('id')->on('orders')->onDelete('cascade');
            $table->foreign('tracking_id')->references('id')->on('trackings')->onDelete('cascade');

            $table->dateTime('completion_date')->nullable();
            $table->timestamps();
        });

As per your solution it looks like it might work for me but I'm not sure where did the $trackingId1 and $trackingId2 came from??? and why passing completion_date twice.

can you please try to update your solution code to match my case ????

thanx

Jun
05
1 week ago
Activity icon

Started a new Conversation Trouble When Updating ManyToMany Pivot Table With Multiple Values

Hi, I have ManyToMany relationship between Orders and tracking stages using a pivot table.

this is how tracking method looks like in my orders model

 public function tracking()
    {
        
        return $this->belongsToMany(Tracking::class, 'order_tracking', 'order_id', 'tracking_id');

    }

so now I can do to fetch data like this

$order = Order::with('tracking')->findOrFail($id);

and I'm doing this to sync() function update database like this

public function update(Request $request, Order $order)
    { 

        $order->tracking()->sync($request->tracking);

        return back();
    }

this is my blade file

@foreach ($order->tracking as $tracker)

<input class="form-check-input" type="checkbox" value="{{$tracker->id}}" name="tracking[]"

	@if($order->tracking->firstWhere('id',$tracker->id))

			checked

	@endif >

@endforeach

Now my customer want to add estimate completion date for every tracking stage and this is where things get messy.

I have added new column to the Pivot table called completion_date like this.

public function up()
    {
        Schema::create('order_tracking', function (Blueprint $table) {

            $table->unsignedBigInteger('order_id');
            $table->unsignedBigInteger('tracking_id');

            $table->foreign('order_id')->references('id')->on('orders')->onDelete('cascade');
            $table->foreign('tracking_id')->references('id')->on('trackings')->onDelete('cascade');

            $table->dateTime('completion_date')->nullable();
            $table->timestamps();
        });
    }

and this is my updated tracking function

public function tracking()
    {
        
        return $this->belongsToMany(Tracking::class, 'order_tracking', 'order_id', 'tracking_id')->withPivot('completion_date');

    }

The problem now is that I have to sync multiple values on pivot table (order_id + tracking_id) and the new completion_date in the update method OrderController?

I'm guessing that Laravel can handle syncing of multiple data but not sure how to do this

Any Ideas ????

May
13
4 weeks ago
Activity icon

Started a new Conversation Verifying Product Slug On Update Is Returning 'The Slug Has Already Been Taken'

This is really surprising to me because I validate all my form unique values on my app in this way but it looks like I'm stucked with product update form

this is my validation role the $request + $id value is getting returned to update method correctly

public function update(Request $request, $id)
{
$request->validate([
            'status' => 'int:1,0',
            'name' => 'required|string',
            'slug' =>"required|string|max:255|unique:products,slug,$id",
         	// ... cont,
        ]);

surprisingly Laravel is returning error "The slug has already been taken."

Any ideas on what is going on????

May
06
1 month ago
Activity icon

Started a new Conversation Should I Upgrade From 5.8 To 8 In One Jump Or Step By Step

hi, I have old Laravel project developed when Laravel 5.8 was fresh, I need to upgrade to most reliable release for from 5.8 to 6 or 7 or maybe 8 ??? but I'm not sure if that is a good option to do.

its not really necessary to move up to 8 I'm fine with 7 or maybe 6.

so what do you recommend should I upgrade to 6 then 7 then 8, is that recommended ????

options wise I'm fine with what 5.8 has to offer because the app is a very basic one and none of the new features in 8 are required for this app.

any recommendation on how to make this upgrade ????

Apr
23
1 month ago
Activity icon

Started a new Conversation Tailwindcss Dropdown List Closes When Mouse Leaves Button On Edge And Firefox Only

I'm struggling with this issue for a couple of days now, I'm having this issue with MS Edge and FireFox only where safari and chrome are doing just fine.

I'm using tailwindcss with Vue.js to show a popup menu when the a mouse hovers over a icon button element on the page.

the popup menu have sets of icon buttons some of them are actually a dropdown menus like this

<span class="relative">

        <select v-model="btn.btneffects" v-on:change="btnUpdater(btn.id, btn.btneffects, 'btneffects')"

          class="appearance-none w-6 py-2 px-4 p-2 shadow-md no-underline bg-white text-grey-dark hover:text-grey-darker rounded font-sans font-semibold border border-grey hover:border-blue btn-primary focus:outline-none active:shadow-none">

          <option value="effect-grow">Grow</option>
          <option value="effect-shrink">Shrink</option>
          <option value="effect-pulse">Pulse</option>
          <option value="effect-push">Push</option>
       
        </select>

      </span>

Till this point every thing works just fine, the problem starts when I try to selected an element from the populated list? the menu closes automatically. I think that is because of the small empty space in between the icon button and the populated list ( please have a look at the image available on the link below ).

https://prnt.sc/11w3gyg

Till this point every thing works just fine, the problem starts when I try to selected an element from the populated list? the menu closes automatically. I think that is because of the small empty space in between the over icon button and the populated list ( please have a look at the image available on the link below ).

https://prnt.sc/11w3gyg

Just to make sure? when I moved the mouse slowly from the button towards the populated list and i can see the menu closes as soon as the mouse in the white space between these to elements.

can anybody advise on how to solve this issue ???

how can I ZERO out the space between the button and the list ?????

all the best

Apr
22
1 month ago
Activity icon

Started a new Conversation CSS Dropdown List Closes When Mouse Leaves Button On Edge And Firefox Only

I'm struggling with this issue for a couple of days now, I'm having this issue with MS Edge and FireFox only where safari and chrome are doing just fine.

I'm using tailwindcss with Vue.js to show a popup menu when the a mouse hovers over a button element on the page.

the popup menu have sets of icon buttons some of them are actually a dropdown menus like this

<span class="relative">

        <select v-model="btn.btneffects" v-on:change="btnUpdater(btn.id, btn.btneffects, 'btneffects')"

          class="appearance-none w-6 py-2 px-4 p-2 shadow-md no-underline bg-white text-grey-dark hover:text-grey-darker rounded font-sans font-semibold border border-grey hover:border-blue btn-primary focus:outline-none active:shadow-none">

          <option value="effect-grow">Grow</option>
          <option value="effect-shrink">Shrink</option>
          <option value="effect-pulse">Pulse</option>
          <option value="effect-push">Push</option>
       
        </select>

      </span>

Till this point every thing works just fine, the problem starts when I try to selected an element from the populated list? the menu closes automatically. I think that is because of the small empty space in between the over icon button and the populated list ( please have a look at the image available on the link below ).

https://prnt.sc/11w3gyg

Just to make sure? when I moved the mouse slowly from the button towards the populated list and i can see the menu closes as soon as the mouse in the white space between these to elements.

can anybody advise on how to solve this issue ???

how can I ZERO out the space between the button and the list ?????

all the best