LoginSignup
4
1

More than 1 year has passed since last update.

【Livewire】protectedプロパティとprivateプロパティの呼び出し方

Last updated at Posted at 2022-12-08

publicの場合

public $count = 1;
--------------------------
Blade側
{{ $count }}

private,protectedの場合

「$this」が必要になります。

protected $count = 1;
private $user;
--------------------------
Blade側
{{ $this->count }}
{{ $this->user }}

意外とここわからんくて詰まった記憶がある。

おまけ:使い分け

publicは開発者目線でユーザーに見られても大丈夫と思えるデータを入れる。
private,protectedにはユーザーに見られたらダメなデータを入れる。

publicでは開発者ツールやソースの表示等で見られてしまうので要注意。
間違ってAPIキーとかpublicにしたら丸見えでスーパー終わ終わタイムが始まる。

4
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
4
1