0

Controller

public function Payment()
    {
        $PayData= array('MainCategory'=>$MainCategory , 'Price'=>$Price , 'AddId'=>$AddId );
        return view('classifieds.Pay')->with('store', $PayData);
    }

pay.blade.php

{{$PayhereData->MainCategory}}

this code is not working , how to pass manualy created aray data to view

3 Answers 3

1

As it is you can pass that array to with() function

like this

public function Payment()
{
    $PayData = array('MainCategory' => $MainCategory, 'Price' => $Price, 'AddId' => $AddId);
    return view('classifieds.Pay')->with($PayData);
}

then in

pay.blade.php

you can call {{ $MainCategory }} and {{ $Price }} and {{ $AddId }}

Sign up to request clarification or add additional context in comments.

Comments

1

Example Data

  $MainCategory = 'cat';
  $Price = 20;
  $AddId = 1;

simply you can use get_defined_vars() to pass all variables ...

  return view('classifieds.Pay',get_defined_vars());

also you can pass as array...

return view('classifieds.Pay',[
    'MainCategory' =>$MainCategory,
    'Price' =>$Price,
    'AddId' =>$AddId,
]);

Comments

1

write code in Your method like

public function Payment()
{
    $PayData = array('MainCategory' => $MainCategory, 'Price' => $Price, 'AddId' => $AddId);
    return view('classifieds.Pay', $PayData );
}

your pay.blade.php

MainCategory  : {{ $MainCategory }} 
Price         : {{ $Price }} 
AddId         : {{ $AddId }}

2 Comments

have you tested your code before answering?? this will make an error if you try to use {{ $MainCategory }} directly in blade as the variable is inside an array.
now you have updated your answer :D you should test your code before answering.

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.