は、だからここ保存クラス変数内のオブジェクトと別の関数でそれを使用する - PHP、laravel
use App\Video;
class HomeController extends Controller
{
protected $video;
public function index()
{
// $video_to_watch is fetched from db and I want to save it and use it in
// another function in this controller
$this -> video = $video_to_watch;
return view('home', compact('video_to_watch'));
}
public function feedback(Request $request)
{
dd($this -> video);
}
}
フィードバックが何らかの理由でnullを返すコードです。
私は()インデックス内
dd($this -> video);
を入れたときに、それがnullで、罰金ではない動作します。
私はここで提案しているもの試してみました:Laravel doesn't remember class variables
が、それは助けにはなりませんでした。
私はそれが愚かな私は見落としていると確信しています。しかし、何が助けになるか分かりませんでした。
もし、同じ要望で 'index()'と 'feedback()'アクションを呼び出すのですか? – Timurib
私は恐れている2つの異なる要求。ありがとう、分かりました。 – beeks