After refresh go back

Posted 11 months ago by evripidesk

I have the below code that is search for security code (that is in my db) and I use form to search it, is working fine but if I hit the refresh button (browser) then I get back with the error , No record found how can I stop it and with the refresh get the normal details

<?php 
 public function searchSecurityCode($id)
     {
       $id=Hashids::decode($id);
       $id = implode(',', $id);

       $security_code = Session::get('security_code');

       $this->validate(request(), [
           'q' => 'required'],
           [
               'q.required'    => 'Please type the security code ',

           ]);
            $q = Input::get ( 'q' );

            $success = Clients::where(function($query) use ($id,$q) {
                                          $query->where('id', 'LIKE', $id)
                                                  ->where('security_code', 'LIKE', $q);

                                      })->get();


            if(count($success) > 0) {
              Session::forget('security_code');
              Session::forget('name');
              $products = Products::with('user’,’clients’)->where(‘client_id','LIKE',$id)->paginate(10);
              $resetsecuritycode = Clients::find($id);
              $resetsecuritycode->security_code = str_random(10);
              $resetsecuritycode->save();

              return view(‘clients.history')->withClients($products);

             }else
            return redirect()->back()->with('status', 'No record founded!');


     }

My route is below

Route::post('/clients/{id}/history/', '[email protected]');

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

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up

Channels

Reply to

Use Markdown with GitHub-flavored code blocks.