nhayder

nhayder

Member Since 2 Years Ago

Doha

Experience Points
50,170
Total
Experience

4,830 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
353
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.

Level 11
50,170 XP
Jul
12
3 months ago
Activity icon

Started a new Conversation Composer Update Is Not Running

i have a laravel 5.8 app since a while ago, now i want to update to 7.

when i attempt to run

composer update

i get

Loading composer repositories with package information
Updating dependencies (including require-dev)

the its stays like this for ever, it looks like composer is not being able to grab dependances neither download them ???

any ideas on how to solve this issue

Jul
07
3 months ago
Activity icon

Started a new Conversation Email Not Delivered After I Implements ShouldQueue

I have a basic contact us from that been working very well, today i have implemented shouldqueue since then i'm getting queue failed with as soon as the worker process the queue.

// controller

        $contact = array_add($email, 'mailto', $admin->others);

        event(new NewContactFormEmailStoredEvent($contact));

// mailable

<?php

class NewContactFormEmailStoredEvent 
{
    use Dispatchable, InteractsWithSockets, SerializesModels;

    public $contact;

    public function __construct($contact)
    {
        $this->contact = $contact;
    }

    public function broadcastOn()
    {
        return new PrivateChannel('channel-name');
    }
}

// listener

<?php

class DiliverContactFormEmailListner implements ShouldQueue
{
    public $tries = 5;
    
    public function __construct()
    {
        //
    }

    public function handle($event)
    {      

        Mail::to($event->contact->mailto)->send(new SendContactFormEmailToDestination($event->contact));

    }
}

any idea????

Jun
26
3 months ago
Activity icon

Replied to How To Run Npm Run Production From Model Class

thank you braunson, i'm already experimenting with exec command right now.

Activity icon

Started a new Conversation How To Run Npm Run Production From Model Class

i'm working on automatic app upgrader class where i can automatically download/unzip upgrade files.

my code is working just fine and things are looking good apart from compiling assets.

basically i need to run this programmatically from a model class after setting up the upgraded files on customer hosting account?

So typically i can manually run

npm run production

My question is how to run NPM commands directly from a model class???

is that possible ???

any recommendations ????

Jun
19
4 months ago
Activity icon

Started a new Conversation Sending Multiple Email Product Suppliers When Order Is Placed

Hi, This is the first time i'm doing this type of app, i'm building a store where suppliers can add their products to front end web page.

when order is placed i need to send emails to all thoses suppliers who have their products added to the cart by the customer.

every order will have average of 5 product max and these products might belong to 1 supplier of multiple suppliers. but i need to send thoses email regardless of how many suppliers are involved.

My question is : what is the laravel way to sending these multiple emails.

currently when and order is place i'm firing an event like this

// event service provider

    protected $listen = [
        \App\Events\NewOrderEvent::class => [
            \App\Listeners\NotifyAdminListener::class, // this will notify website admin of the new order
            \App\Listeners\NewOrderCustomerConfirmationListener::class, // this will confirm order to customer
        ],
    ];

the new order event

class NewOrderEvent
{
    use Dispatchable, InteractsWithSockets, SerializesModels;

    public $customer;
    
    /**
     * Create a new event instance.
     *
     * @return void
     */
    public function __construct($customer)
    {
        $this->customer = $customer;
    }

    /**
     * Get the channels the event should broadcast on.
     *
     * @return \Illuminate\Broadcasting\Channel|array
     */
    public function broadcastOn()
    {
        return new PrivateChannel('channel-name');
    }
}

this is the NewOrderCustomerConfirmationListener listener

class NewOrderCustomerConfirmationListener implements ShouldQueue
{
    
    public $tries = 5;

    /**
     * Create the event listener.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Handle the event.
     *
     * @param  NewOrderEvent  $event
     * @return void
     */
    public function handle(NewOrderEvent $event)
    {
        Mail::to($event->customer->email)->send(new CustomerOrderConfirmation());
    }
}

this is the NotifyAdminListener listener

class NotifyAdminListener implements ShouldQueue
{
    public $tries = 5;
    
    /**
     * Create the event listener.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Handle the event.
     *
     * @param  object  $event
     * @return void
     */
    public function handle($event)
    {
        Mail::to('[email protected]')->send(new NewOrder());
    }
}

These emails are being queued and they are working as expected so there is no issue up to here

so my question is ???

what is the best way to send and email to all suppliers attached to this order, Basically there might be is supplier or multiple supplier but the solution should fire all of the email properly.

  • should i add another listener to that event then loop through suppliers to fire these emails ???

  • is broadcast and option at this point ????

not sure which way to go ???

any recommendations ???

Jun
05
4 months ago
Activity icon

Replied to Adding Multiple Products To Cart With Same ID

@martinbean unfortunately i'm way ahead make this type of change to the app now.

you seen, the main issue that i'm facing with the cart code above is that i'm building the cart according to product id.

and checking it if the ide exist in the cart to code the logic, SKU can solve this issue but i dont think it doable at this point.

Activity icon

Started a new Conversation Adding Multiple Products To Cart With Same ID

in my shopping cart app i'm building customers carts using addToCart method, the method checks if the cart is empty or if product already exist in the cart, and if the newly added product ID exist in the cart i'm only adding the qty to existing product in the cart.

    public function store($id)
    {

        $product = Product::find($id);
 
        if(!$product) {
 
            abort(404);
 
        }
 
        $cart = session()->get('cart');
 
        // if cart is empty then this the first product
        if(!$cart) {
 
            $cart = [
                    $id => [
                        "name" => $product->name,
                        "qty" => $request->quantity,
                        "price"=>$product->price,
                        "color" => $request->color,
                        "size" => $request->size,
                        "image" => $product->poster,
                    ]
            ];
 
            session()->put('cart', $cart);
        
            return redirect()->back()->with('success', 'Product added to cart successfully!');
        }
 
        // if cart not empty then check if this product exist then increment quantity
        if(isset($cart[$id])){
            
                $cart[$id]['qty'] = $request->quantity;
     
                session()->put('cart', $cart);
     
                return redirect()->back()->with('success', 'Product added to cart successfully!');
 
        }
 
        // if item not exist in cart then add to cart with quantity
        $cart[$id] = [

            "name" => $product->name,
            "qty" => $request->quantity,
            "price"=>$product->price,
            "color" => $request->color,
            "size" => $request->size,
            "image" => $product->poster,

        ];
 
        session()->put('cart', $cart);
 
        return redirect()->back()->with('success', 'Product added to cart successfully!');


    }

I'm updating the the app product so every product has multiple options (size, Color and qty), so basically a user can add the same product to the cart multiple times as not and it has deferent option (size, color, qty).

a good example for this will be a shirt? a customer can add same shirt multiple times in the cart as long as the (size or colors ) are deferent

any idea on how to achive this type of cart.

May
27
4 months ago
Activity icon

Replied to Unserialize Cart Data Not Working

@michaloravec thank you for the help :-)

its working now

Activity icon

Started a new Conversation Unserialize Cart Data Not Working

i'm save my cart products as unserialized data from my cart session.

        $order = new Order();

        $order->cart = serialize($cart);
        $order->code = strtoupper(str_random(15));
        $order->user_id = Auth::user()->id;

        $order->save();

now i need to unserialize the data to use it in my blade file, this is the function i'm using

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

        $orders->transform(function($order, $key){

            $order->cart = unserialize($order->cart);

            return $order;

        });

        dd($orders);


i'm getting this error

BadMethodCallException
Call to undefined method App\Order::transform()

what seems to be the problem? and how can i unserialize my data;

any ideas ???