DateTime Fields Problem |
hello i have a problem with ci4 and datetime fields. i am using the code below
Code: protected $useTimestamps = true; the comment created at and comment updated at are inserted fine in the database but when i try to display them with humanize format it gives me an error Call to a member function humanize() on string the code from my view Code: $c->com_created_at->humanize() ps im using different names than created_at and updated_at because i need them to be like that.
(01-15-2021, 02:33 PM)thedragon655 Wrote:(01-15-2021, 11:11 AM)iRedds Wrote: Does the $c variable contain an instance of the Entity class?yes it does contain an entity class of comments and i display them with a join to the users table in order to display the correct user comment Have you defined the $dates property of the class? As here. PHP Code: class User extends Entity https://codeigniter.com/user_guide/model...e-mutators
(01-15-2021, 06:49 PM)iRedds Wrote:(01-15-2021, 02:33 PM)thedragon655 Wrote:(01-15-2021, 11:11 AM)iRedds Wrote: Does the $c variable contain an instance of the Entity class?yes it does contain an entity class of comments and i display them with a join to the users table in order to display the correct user comment
edit i fixed it maybe its a bug i had to do what you said in the entity class plus i had to change the getresult method to findall
return $this ->where('post_id',$post_id) ->orderBy('comments.com_created_at','DESC') ->join('users', 'comments.user_id = users.id' ) ->findAll(); |
Welcome Guest, Not a member yet? Register Sign In |