princeoo7
1 month ago

how to access time stamp in api controller for pivot table

Posted 1 month ago by princeoo7

As the title for the question says, How can i access the timestamp for a pivot table.

My model for user:

public function histories() {
        return $this->belongsToMany(UserFeed::class, 'histories')->withTimestamps();
    }

API Call controller :

$records = Auth::user()
            	->histories()
		->latest()
		->paginate(config("app.rec_limit"));

But I cannot either see the pivot table nor the timestamp data for the records been fetched !

what I get is only history records and nothing else.

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