Hi , i have collection like that
#items: array:3 [▼
0 => App\Models\FileActivity {#1620 ▼
#connection: "mysql"
#table: "file_activities"
#primaryKey: "id"
#keyType: "int"
+incrementing: true
#with: []
#withCount: []
+preventsLazyLoading: false
#perPage: 15
+exists: true
+wasRecentlyCreated: false
#escapeWhenCastingToString: false
#attributes: array:13 [▼
"id" => 27
"file_id" => null
"employee_id" => null
"user_id" => 1
"name" => "Updated Client wReagandd Amos Gallegos Joyced On Field firstname By John Doe"
"old" => "wReagand"
"new" => "wReagandd"
"note" => null
"section" => "Client"
"status" => 0
"is_read" => 0
"created_at" => "2022-09-14 01:07:51"
"updated_at" => "2022-09-14 01:07:51"
]
#original: array:13 [▶]
#changes: []
#casts: []
#classCastCache: []
#attributeCastCache: []
#dates: []
#dateFormat: null
#appends: []
#dispatchesEvents: []
#observables: []
#relations: []
#touches: []
+timestamps: true
#hidden: []
#visible: []
#fillable: array:10 [▶]
#guarded: array:1 [▶]
}
1 => App\Models\FileActivity {#1619 ▶}
2 => App\Models\FileActivity {#1618 ▶}
and i added
public function getReadTimeAttribute()
{
return Carbon::createFromTimeStamp(strtotime($this->attributes['created_at']))->diffForHumans();
}
and i send it as api
the api want to insert it like
${value.read_time}
with javascript , so there's way to visible it with api json like that with the data
0
id 27
file_id null
employee_id null
user_id 1
name "Updated Client wReagandd Amos Gallegos Joyced On Field firstname By John Doe"
old "wReagand"
new "wReagandd"
note null
section "Client"
status 0
is_read 0
created_at "2022-09-13T23:07:51.000000Z"
updated_at "2022-09-13T23:07:51.000000Z"
1
id 28
file_id null
employee_id null
user_id 1
name "Updated Client wReagandd Amos Gallegos Joyced On Field password By John Doe"
old "y$vXcuSVuu2KyTNkexZp8WruC90C.AeT1J4lvtEQ58PUWLs1yF9GnBG"
new "y$l/MMAddjoHG1oJBdswb1ReEQCYZfP6sQx17gBLFljhF9mIwbPDIcO"
note null
section "Client"
status 0
is_read 0
created_at "2022-09-13T23:07:51.000000Z"
updated_at "2022-09-13T23:07:51.000000Z"
2
id 29
file_id null
employee_id null
user_id 1
name "Updated Client wReagandd Amos Gallegos Joyced On Field updated_at By John Doe"
old "2022-09-14 01:00:14"
new "2022-09-14 01:07:51"
note null
section "Client"
status 0
is_read 0
created_at "2022-09-13T23:07:51.000000Z"
updated_at "2022-09-13T23:07:51.000000Z"