I have a collection that I am passing to my view. There are 3 rows:
Collection {#869 ▼
#items: array:3 [▼
0 => Customer {#868 ▼
#table: "customers"
#guarded: []
#connection: "mysql"
#primaryKey: "id"
#keyType: "int"
+incrementing: true
#with: []
#withCount: []
#perPage: 15
+exists: true
+wasRecentlyCreated: false
#attributes: array:10 [▼
"id" => 17
"business_id" => 1
"first_name" => "Bob"
"last_name" => null
"email" => null
"phone" => null
"sent_at" => null
"created_at" => "2017-10-03 16:18:30"
"updated_at" => "2017-10-03 16:18:30"
"deleted_at" => null
]
#original: array:10 [▶]
#changes: []
#casts: []
#dates: []
#dateFormat: null
#appends: []
#dispatchesEvents: []
#observables: []
#relations: []
#touches: []
+timestamps: true
#hidden: []
#visible: []
#fillable: []
}
1 => Customer {#867 ▶}
2 => Customer {#866 ▶}
]
}
Out of these 3 customers 1 of them has a "sent_at" column that is null that I want to count within my view. I understand you can do this in the controller but I want to modify the collection in the view.
I have tried this in my view and it returns no results:
$customers_pending = $customers_all->where('sent_at', null);
$customers_pending->count();
dd($customers_pending);
I guess I'm not fully understanding collections and modifying them. $customers_pending should return = 1
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire