Tagged: 

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #377
    jacob_smith
    Participant

    I have view Blade component that receives data from a controller. What are some the reasons this data will be passed upwards to the component?

    If I have a controller:

    public function index() {
    $users = User::all();
    return view(‘users’, [‘users’ => $users]);
    }

    View Component:

    <div>
    @foreach($users as $user)
    <x-users :user = “$user”>
    @endforeach
    </div>

    Class Component:

    public $user;

    public function __construct($user) {
    this -> user = $user
    }

    • This topic was modified 1 year, 2 months ago by jacob_smith.
Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.