1

I have eCommerce systems with ads so I want to count every click from the ad card , so I add ad=true to check it in my controller. It counts fine and work smooth

http://127.0.0.1:8000/product/3?ad=true

but the problem is that if the page has been refreshed it will count more and more , so I need a way to remove this parameter how can I do this. if there any way else I am open to suggestions

6
  • 1
    after processing the request, you need to redirect to a new url without the parameters. Commented Aug 23, 2018 at 2:19
  • it seems as a good idea but is there any ideas to change the ad value or remove it directly !! Commented Aug 23, 2018 at 2:26
  • @user10076385 If you want to use redirection, it will be like return redirect()->route('route.name', ['parameter' => 'value']); Commented Aug 23, 2018 at 2:32
  • You can use cookies here, store a variable which holds the information to count or to not count, every time your controller is called just check for that variable and do the counts. for more info see laravel.com/docs/5.6/requests#cookies Commented Aug 23, 2018 at 2:38
  • I don't get how to store cookie from url ? Commented Aug 23, 2018 at 2:53

2 Answers 2

1

Upon processing the request, you can just redirect to the same route without the parameters.

E.g.,

public function action(Request $request)
{
    /* Process the Request */
    return redirect('theRouteName');
}
Sign up to request clarification or add additional context in comments.

Comments

1

You can try this

Route::get('/product/{id}', 'YourController@funciton');

public function multi_delete($id) {
    $count = Input::get('ad');
    // your code goes here
    \Redirect::route('product', $id)

}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.