5
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

新時代はAlpine.jsだ~世界中全部(Alpine.jsに)変えてしまえば~↑↑Advent Calendar 2022

Day 8

【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にしたら丸見えでスーパー終わ終わタイムが始まる。

5
2
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
5
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?