How to solve this? Undefined offset: 0 (View:)

Posted 4 months ago by anonymouse703

When I dd($users) I get some data.

Collection {#336 ▼
  #items: array:1 [▼
    0 => User {#330 ▼
      #fillable: array:11 [▶]
      #hidden: array:2 [▶]
      #connection: "mysql"
      #table: "users"
      #primaryKey: "id"
      #keyType: "int"
      +incrementing: true
      #with: []
      #withCount: []
      #perPage: 15
      +exists: true
      +wasRecentlyCreated: false
      #attributes: array:21 [▶]
      #original: array:21 [▼
        "id" => 1
        "first_name" => "Jerome"
        "last_name" => "Villaver"
        "middle_name" => "Llacuna"
        "achievement_id" => null
        "country_id" => 1
        "provider" => "system"
        "avatar" => "avatar.png"
        "avatar_url" => null
        "email" => "[email protected]"
        "status" => 0
        "email_verified_at" => null
        "password" => "ykyU8Rcw3ZroKD2UV3r.0uj.Yilar30EMTyZ5PvOd.IT6WEwYoZ4q"
        "remember_token" => null
        "availabity" => null
        "address" => null
        "educaction_id" => null
        "notes" => null
        "rating_id" => null
        "created_at" => "2019-02-18 00:44:59"
        "updated_at" => "2019-02-18 00:44:59"
      ]

and my view is something like this

@foreach($users as $user)

{{$user->last_name}},{{$user->first_name}},{{$user->middle_name}}

@endforeach

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.