PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, January 19, 2022

[FIXED] Missing required parameters for [Route: claim_card] [URI: admin/claim_card/{giftcard_id}/{layout_id}/{user_id}/{color_id}]. - Laravel

 January 19, 2022     laravel, laravel-5, php     No comments   

Issue

I am new to laravel and when created a route, this error is displayed. I am passing complete parameters and can't locate the error.

Here's the route:

Route::get('/admin/claim_card/{giftcard_id}/{layout_id}/{user_id}/{color_id}' , 'UserController@claim_card')->name('claim_card');

Here's the function:

public function claim_card($giftcard_id , $layout_id , $user_id , $color_id)
{
    $card = giftcard_codes::where([['is_active', '=' , 1], ['giftcard_id', '=' ,$giftcard_id], ['layout_id', '=' ,$layout_id]])->first();
    if ($card) {
        $user = User::where('id', $user_id)->first();
        $lay = point_prizes::where('id', $layout_id)->first();
        if ($user->points >= $lay->points) {
            $us['points'] = $user->points - $lay->points;
            $c['is_active'] = 0;
            $co['color_id'] = $color_id;
            $co['is_pending'] = 2;

            cliaim_prizes_transactions::where([['user_id' , $user_id] , ['giftcard_id' , $giftcard_id] , ['layout_id' , $layout_id]])->first()->update($co);

                    $al = new user_alerts();
                    $al->user_id = $user_id;
                    $al->alert = 'Successfully Claimed Giftcard';
                    $al->alert_main = $card->code;
                    $al->save();

                    redeem__requests::where([['giftcard_id' , $giftcard_id] , ['layout' , $layout_id] , ['user_id' , $user_id] , ['is_active' , 1]])->first()->update($c);
                    giftcard_codes::where([['is_active', 1], ['giftcard_id', $giftcard_id], ['layout_id', $layout_id]])->orderby('id', 'DESC')->first()->update($c);
                    return view('admin.redeem_requests' , ['data' => redeem__requests::where('is_active' , 1)->get() , 'alert' => 'Giftcard Given Successfully']);
        }
    }
    else {
        return view('admin.redeem_requests' , ['data' => redeem__requests::where('is_active' , 1)->get() , 'alert' => 'No Code Exists']);
    }
}

Here's the view(where I am passing these):

<a href="{{action('UserController@claim_card' , [$gift , $lay , $user , $c->id])}}">

Any help would be appreciated.


Solution

You defined a route name claim_card, so you can call it by named route with parameter as like :

<a href="{{ route('claim_card' , ['giftcard_id' => $gift , 'layout_id' => $lay , 'user_id' => $user , 'color_id' => $c->id]) }}">


Answered By - sta
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing