Our Black Friday sale is now live! All individual subscriptions are 50% OFF. This week only!

ziaakbari

ziaakbari

Member Since 8 Months Ago

Experience Points
650
Total
Experience

4,350 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
0
Lessons
Completed
Best Reply Awards
0
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 1
650 XP
Sep
07
2 months ago
Activity icon

Replied to V-bind Is Not Working With Min, Vuejs

Yes, u r right, I create my own date component

Sep
06
2 months ago
Activity icon

Replied to V-bind Is Not Working With Min, Vuejs

thanks, yes, md-input doesn't support min attribute, md-datepicker has format problem to use

[Vue warn]: The datepicker value is not a valid date. Given value: 2020-09-24T19:30:00.000Z, format: dd/MM/yyyy

Activity icon

Started a new Conversation V-bind Is Not Working With Min, Vuejs

hi there, I have an input type is date I want the input to accept only the dates after current date, I works in like bellow

   <md-field>
          <md-input type="date" v-model="selectedDate" required min="2020-09-06"></md-input>
  </md-field>

but not working like this

   <md-field>
          <md-input type="date" v-model="selectedDate" required :min="minDate"></md-input>
   </md-field>

the variable binded to

  data: () => ({
    minDate: '2020-09-06',
  }),

any help please

Activity icon

Replied to Vue Is Not Setting Max Value Input Dynamic

hi dear, I have the same problem, this solution is not working

my input is

  <md-field>
          <md-input type="date" v-model="selectedDate" required  :min="minDate"></md-input>
   </md-field>

and variable binded

  data: () => ({
    minDate: '2020-09-06',
  }),

could you help me please

Aug
11
3 months ago
Activity icon

Replied to How To Initialize A Global Variable Inside One Function And Access In Another Function Inside Controller

Thanks @michaloravec for answering

I tried session, my front is vue n route is defined in api.php, as api is stateless, session is not accessible through api, I'm looking for a solution to store $customerId in the backend for later request.

I found a solution using session, but don't know is it a good practice or not. I defined my route in web.php and call that in vuejs. please give your Ideas if it's not a bad practice I can go ahead?

thanks

Activity icon

Started a new Conversation How To Initialize A Global Variable Inside One Function And Access In Another Function Inside Controller

Hi there, I know a global variable should be initialized by contractor. what if need to init a global variable inside one function and access it in another function.

this is my first function

	public $customerId;

    public function store(CheckoutRequest $request)
    {
            try {
                $customer = Stripe::customers()->create([
                    'source' => $request->stripeToken,
                    'email' => $request->email,
                    'description' => $request->name
                ]);

                $this->customerId = $customer->id;
		$this->chargeCustomer($request, $customer->id);
                return redirect()->route('shipper.payment')->with('success_message', 'Thank you! your payment was successfull.');
            } catch (Exception $e) {
                return back()->withErrors('Error! ' . $e->getMessage());
            }
    }

this is my second function

    public function paymentDetails()
    {
        return $this->customerId;
    }

I'm creating customer in Stripe and assign created customer id to $customerId global variable, I need $customerId insid paymentDetails function which gets calling by another route, but paymentDetails return null. could anyone help please, how to get customer id in other functions?

Aug
05
3 months ago
Activity icon

Replied to How To Access Array Inside An Object?

It looks src_des property doesn't exist in this object. I see the same result when I return $job->shipper->addresses->xyz, wheres xyz doesn't exist.

Activity icon

Started a new Conversation How To Access Array Inside An Object?

Hi there, I have a function in my controller like bellow

	public function notifyShipper(){
        	$job = Job::with('shipper', 'jobstatus')->find($id);
        	return $job;
	}

returned object in console is like bellow

 {
	....
	....
	shipper: {
		addresses:{
			name: "Ali"
			src_des: [
				{
				  	id: 21,
           			  	company: "zia",
            			  	address: "some fake address",
				},
				{
				  	id: 22,
           			  	company: "xia",
            			  	address: "some fake address",
				}
			]
		}
	}
}

if I return $job->shipper->addresses->name, I get "Ali", but if I return $job->shipper->addresses->src_des, I get nothing

Aug
04
3 months ago
Activity icon

Started a new Conversation Problem In Life Vps Server (Vue And Laravel Api)

Hi there,

I made a Laravel app with Vue in frontend, my vue is inside resource/js folder. I uploaded the whole project to a vps server, created the database and migrated my tables and seeders. until here there is no problem and I see the home page in the browser. but, other pages which retrieve data from database I call http://104.154.95.189/api/route-name end point but it goes to http://localhost:8000/api/route-name, (showing in console), I set APP_URL=http://104.154.95.189 in .env file and cleared npm and laravel caches not solved my problem could anyone help me please? thanks in advance

this is my page http://104.154.95.189/#/order/origin

Jul
10
4 months ago
Activity icon

Replied to Nested Loop In Laravel Controller Not Working ("message": "Invalid Argument Supplied For Foreach()",)

thanks @frankielee that helped me to find the solution

        if (is_array($carriers)) {
            foreach($carriers as $carrier){
                foreach($carrier->city_rate as $rate){
                    echo $rate->min_rate;
                }
            }
        }else{
            $carriers = json_decode($carriers);
            foreach($carriers as $carrier){
                foreach($carrier->city_rate as $rate){
                    echo $rate->min_rate;
                }
            }
        }
Activity icon

Replied to Nested Loop In Laravel Controller Not Working ("message": "Invalid Argument Supplied For Foreach()",)

if I try to access like this

return $carriers[0]->city_rate;

or

return $carriers[0]->city_rate[0]->min_rate;

I get nothing in the reply, but the status is 200 ok

I can access the first_name or last_name of $carriers as bellow

return $carriers[0]->first_name;

city_rate is not an actual element of $carriers array, city_rate comes when I access Carrier model, look at bellow

$carriers = Carrier::with('cityRate')->get();

in above 'cityRate' is a function in Carrier model

It seems city_rate is not accessible as first_name is in $carriers array.

any Idea? please,

Activity icon

Replied to Nested Loop In Laravel Controller Not Working ("message": "Invalid Argument Supplied For Foreach()",)

thanks @bobbybouwmann for replying me

I do everything inside a controller, not in a view. front-end is vue, for now I'm calling my api in Postman, I get the error in postman

Activity icon

Started a new Conversation Nested Loop In Laravel Controller Not Working ("message": "Invalid Argument Supplied For Foreach()",)

this is my array

$carriers = Carrier::with('cityRate')->get();

when I return $carriers directly from controller i get the following.

[
    {
        "id": 1,
        "first_name": "Zia",
        "last_name": "Akbari",
        "city_rate": [
            {
                "id": 1,
                "min_rate": 25,
                "_0k_1k": 5,
                "_1k_2k": 4.5,
                "_2k_3k": 4,
                "_3k_4k": 3.5,
                "_4k_5k": 3,
                "_5k_10k": 2.5,
                "above_10k": 2,
                "fsc": 25,
                "transit_day": 1,
                "pivot": {
                    "carrier_id": 1,
                    "rate_id": 1
                },
                "cities": [
                    {
                        "id": 1,
                        "name": "Holtsville",
                        "state_id": 1,
                        "created_at": null,
                        "updated_at": null,
                        "pivot": {
                            "rate_id": 1,
                            "city_id": 1,
                            "type": "source",
                            "created_at": "2020-07-10T04:19:06.000000Z",
                            "updated_at": "2020-07-10T04:19:06.000000Z"
                        }
                    },
                    {
                        "id": 2,
                        "name": "Fishers Island",
                        "state_id": 1,
                        "created_at": null,
                        "updated_at": null,
                        "pivot": {
                            "rate_id": 1,
                            "city_id": 2,
                            "type": "destination",
                            "created_at": "2020-07-10T04:19:06.000000Z",
                            "updated_at": "2020-07-10T04:19:06.000000Z"
                        }
                    }
                ]
            },
            {
                "id": 4,
                "min_rate": 19,
                "_0k_1k": 9,
                "_1k_2k": 8,
                "_2k_3k": 7,
                "_3k_4k": 6,
                "_4k_5k": 5,
                "_5k_10k": 4,
                "above_10k": 3,
                "fsc": 2,
                "transit_day": 1,
                "created_at": "2020-07-11T04:40:18.000000Z",
                "updated_at": "2020-07-11T04:40:18.000000Z",
                "pivot": {
                    "carrier_id": 1,
                    "rate_id": 4
                },
                "cities": [
                    {
                        "id": 4,
                        "name": "Anchorage",
                        "state_id": 2,
                        "created_at": null,
                        "updated_at": null,
                        "pivot": {
                            "rate_id": 4,
                            "city_id": 4,
                            "type": "source",
                            "created_at": "2020-07-11T04:40:18.000000Z",
                            "updated_at": "2020-07-11T04:40:18.000000Z"
                        }
                    },
                    {
                        "id": 2,
                        "name": "Fishers Island",
                        "state_id": 1,
                        "created_at": null,
                        "updated_at": null,
                        "pivot": {
                            "rate_id": 4,
                            "city_id": 2,
                            "type": "destination",
                            "created_at": "2020-07-11T04:40:18.000000Z",
                            "updated_at": "2020-07-11T04:40:18.000000Z"
                        }
                    }
                ]
            },
            {
                "id": 5,
                "min_rate": 6,
                "_0k_1k": 10,
                "_1k_2k": 9,
                "_2k_3k": 8,
                "_3k_4k": 7,
                "_4k_5k": 6,
                "_5k_10k": 5,
                "above_10k": 4,
                "fsc": 3,
                "transit_day": 2,
                "created_at": "2020-07-11T04:40:51.000000Z",
                "updated_at": "2020-07-11T04:40:51.000000Z",
                "pivot": {
                    "carrier_id": 1,
                    "rate_id": 5
                },
                "cities": [
                    {
                        "id": 2,
                        "name": "Fishers Island",
                        "state_id": 1,
                        "created_at": null,
                        "updated_at": null,
                        "pivot": {
                            "rate_id": 5,
                            "city_id": 2,
                            "type": "source",
                            "created_at": "2020-07-11T04:40:51.000000Z",
                            "updated_at": "2020-07-11T04:40:51.000000Z"
                        }
                    },
                    {
                        "id": 5,
                        "name": "Sitka",
                        "state_id": 2,
                        "created_at": null,
                        "updated_at": null,
                        "pivot": {
                            "rate_id": 5,
                            "city_id": 5,
                            "type": "destination",
                            "created_at": "2020-07-11T04:40:51.000000Z",
                            "updated_at": "2020-07-11T04:40:51.000000Z"
                        }
                    }
                ]
            }
        ]
    },
    {
        "id": 2,
        "first_name": "amin",
        "last_name": "amini",
        "city_rate": [
            {
                "id": 2,
                "min_rate": 23,
                "_0k_1k": 9,
                "_1k_2k": 8,
                "_2k_3k": 7,
                "_3k_4k": 6,
                "_4k_5k": 5,
                "_5k_10k": 4,
                "above_10k": 3,
                "fsc": 2,
                "transit_day": 1,
                "created_at": "2020-07-10T04:27:56.000000Z",
                "updated_at": "2020-07-10T04:27:56.000000Z",
                "pivot": {
                    "carrier_id": 2,
                    "rate_id": 2
                },
                "cities": [
                    {
                        "id": 1,
                        "name": "Holtsville",
                        "state_id": 1,
                        "created_at": null,
                        "updated_at": null,
                        "pivot": {
                            "rate_id": 2,
                            "city_id": 1,
                            "type": "source",
                            "created_at": "2020-07-10T04:27:56.000000Z",
                            "updated_at": "2020-07-10T04:27:56.000000Z"
                        }
                    },
                    {
                        "id": 5,
                        "name": "Sitka",
                        "state_id": 2,
                        "created_at": null,
                        "updated_at": null,
                        "pivot": {
                            "rate_id": 2,
                            "city_id": 5,
                            "type": "destination",
                            "created_at": "2020-07-10T04:27:56.000000Z",
                            "updated_at": "2020-07-10T04:27:56.000000Z"
                        }
                    }
                ]
            },
            {
                "id": 3,
                "min_rate": 34,
                "_0k_1k": 9,
                "_1k_2k": 7,
                "_2k_3k": 5,
                "_3k_4k": 4,
                "_4k_5k": 3,
                "_5k_10k": 2,
                "above_10k": 1,
                "fsc": 20,
                "transit_day": 11,
                "created_at": "2020-07-10T04:29:26.000000Z",
                "updated_at": "2020-07-10T04:29:26.000000Z",
                "pivot": {
                    "carrier_id": 2,
                    "rate_id": 3
                },
                "cities": [
                    {
                        "id": 2,
                        "name": "Fishers Island",
                        "state_id": 1,
                        "created_at": null,
                        "updated_at": null,
                        "pivot": {
                            "rate_id": 3,
                            "city_id": 2,
                            "type": "source",
                            "created_at": "2020-07-10T04:29:26.000000Z",
                            "updated_at": "2020-07-10T04:29:26.000000Z"
                        }
                    },
                    {
                        "id": 4,
                        "name": "Anchorage",
                        "state_id": 2,
                        "created_at": null,
                        "updated_at": null,
                        "pivot": {
                            "rate_id": 3,
                            "city_id": 4,
                            "type": "destination",
                            "created_at": "2020-07-10T04:29:26.000000Z",
                            "updated_at": "2020-07-10T04:29:26.000000Z"
                        }
                    }
                ]
            }
        ]
    }
]

this is the nested loop structure

    foreach($carriers as $carrier){
        foreach($carrier->city_rate as $rate){
            echo $rate->min_rate;
        }
    }

as you can see in the above array $city_rate is nested, my target is to get each min_rate from $city_rate

but when I call the target api in postman I get the following error

{
    "message": "Invalid argument supplied for foreach()",
    "exception": "ErrorException",
    "file": "C:\Users\AMU CLOUDS\Desktop\ZIA\laravel-vue\app\Http\Controllers\CalculatorController.php",
    "line": 71,
    "trace": [
        {
            "file": "C:\