Share value between function in same controller

Posted 9 months ago by zettz

Hi there, I need help on how to share result between function on the same controller.

For example: search function results can be reuse at another function in the same controller.

Current controller:

public function searchProduct ()
    $search = Product::find(\Request::get('barcode'));
public function show ()
    $user = User::All();
    $result = $this->searchProduct(); // this line always return null
    return view('products.result', compact('user', 'result'));

So, how can I get the searchProduct() result on the show() function?

Thank you.

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

Reply to

Use Markdown with GitHub-flavored code blocks.