Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mikon's avatar
Level 1

Register the search

hello everybody , i have a question , i created a search function with filters , now i have to register the serarch , so each user can register his search and display in his profile , any idea how to do it ? thanks in advance!

0 likes
1 reply
Sergiu17's avatar
Sergiu17
Best Answer
Level 60

Hi, if you mean for example filtering posts or products, then create a new table user_searches, with id, user_id, search, type

public function search(Request $request) {
	$search = UserSearch([
		'user_id' => auth()->id(),
		'search' => json_encode($request->validated()),
		'type' => 'App\Models\Post'
	])
}

something like this

Please or to participate in this conversation.