Neeraj1005
1 month ago
206
1
Laravel

ErrorException Unresolvable dependency resolving [Parameter #0 [ <required> $auth_profile ]] in class App\View\Components\userprofile\profileInfo (View: C:\laragon\www\acl\resources\views\userprofile\profile-page.blade.php) http://acl.test/auth_profile/1/

Posted 1 month ago by Neeraj1005

In my project, I'm using the component, This time I pass the variable correctly but I don't know why this error occurs?

COntroller methods

   public function show(User $auth_profile)
    {
        return view('userprofile.profile-page', compact('auth_profile'));
    }

blade file resources/views/userprofile/profile-page.blade.php

   <h1 class="h3 mb-3">Profile Information</h1>

    <div class="row">

        <div class="col-md-5 col-xl-4">

            <x-userprofile.profile-info :auth_profile="$auth_profile" />

        </div> <!-- end col-md-5 col-xl-4 -->

component file resources/views/components/userprofile/profile-info.php

    <div class="card-box text-center">
        <img src="{{ $auth_profile->profile_photo_url }}" class="rounded-circle avatar-xl img-thumbnail" alt="profile-image">

        <h4 class="text-muted">{{ $auth_profile->full_name }}</h4>

        {{-- <button type="button" class="btn btn-success btn-xs waves-effect mb-2 waves-light">Follow</button>
        <button type="button" class="btn btn-danger btn-xs waves-effect mb-2 waves-light">Message</button> --}}

        <div class="text-left mt-3">

            @if($auth_profile->description)

            <h4 class="font-13 text-uppercase">{{ __('About Me :') }}</h4>

            <p class="text-muted font-13 mb-3">
                {{ $auth_profile->description ?? '' }}
            </p>
            @endif

            <p class="text-muted mb-2 font-13"><strong>Full Name :</strong> <span class="ml-2">{{ $auth_profile->full_name }}</span></p>

            <p class="text-muted mb-2 font-13"><strong>Mobile :</strong><span class="ml-2">{{ $auth_profile->mobile_number ?? '' }}</span></p>

            <p class="text-muted mb-2 font-13"><strong>Email :</strong> <span class="ml-2 ">{{ $auth_profile->email }}</span></p>

            {{-- <p class="text-muted mb-1 font-13"><strong>Location :</strong> <span class="ml-2">USA</span></p> --}}
        </div>

ANd this is the component class

<?php

namespace App\View\Components\userprofile;

use Illuminate\View\Component;

class profileInfo extends Component
{
    public $auth_profile;

    /**
     * Create a new component instance.
     *
     * @return void
     */
    public function __construct($auth_profile)
    {
        $this->auth_profile = $auth_profile;
    }

    /**
     * Get the view / contents that represent the component.
     *
     * @return \Illuminate\View\View|string
     */
    public function render()
    {
        return view('components.userprofile.profile-info');
    }
}

Routes

 Route::resource('auth_profile', 'UserProfileController');

@michaloravec @Sinnbeck could you please tell me this what I did wrong?

Please sign in or create an account to participate in this conversation.