0
1

More than 3 years have passed since last update.

引数の渡し方

Posted at

今日はlaravelにおいてviewファイルへの引数の渡し方について記録していくよ~

TestController.php

  public function test(){
   $data1 = 1;
  $data2 = 2;

   return view('test_view' , ['data1' => $data1 , 'data2' => $data2 ]);
}//1 2

compact関数を使って同じ出力になる書き方:

TestController.php

  public function test(){
   $data1 = 1;
  $data2 = 2;

   return view('test_view' , compact('data1' , 'data2'));
}//1 2

以上だよお~

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1