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

Kaustubh's avatar

How to pass $id from controller to route and route to controller

Here is my code

Controller

class SellerController extends Controller
{
    public function __construct()
    {
        $this->middleware('auth:seller');
    }

    public function index()
    {        
        $id = Auth::id();
        if(Auth::user()->phoneconfirmed==0)
        {
            return redirect()->route('seller/sms',[$id]);
        }
        return redirect('seller/sellerdashboard');
    }
}

Route

Route::get('seller/sms/{$id}', 'seller\way2sms\func@hello');

Controller

class func extends sms
{
    public function hello($id){
      $phone = DB::table('sellers')->where('id', $id)->pluck('phone')->first();
      $msg = DB::table('sellers')->where('id', $id)->pluck('phonetoken')->first();
      dd($id);
      sendWay2SMS ( '8187893343' , 'P7349Q' ,  $phone, $msg); 
      return view('seller.dashboard.otp');  
   } 
}

It dosent work can you suggest me the right way

0 likes
3 replies
mushti's avatar
mushti
Best Answer
Level 1

You can do something like this:

if(Auth::user()->phoneconfirmed==0)
{
    return redirect('/seller/sms/'.$id);
}
4 likes

Please or to participate in this conversation.