0
<?php

namespace App\View\Components;

use Illuminate\View\Component;

class Admin.-newclubform extends Component

{
    /**
     * Create a new component instance.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Get the view / contents that represent the component.
     *
     * @return \Illuminate\Contracts\View\View|\Closure|string
     */
    public function render()
    {echo "demo";
        return view('components.admin.-newclubform');
    }
}

enter image description here

I use php artisan make:component Admin.Newclubform command to create component in Admin Folder. views section working but class is ignored.

php artisan make:component Admin.Newclubform creates all class and view . class is generated by artisan command enter image description here

3
  • As far as I know, Admin.Newclubform is not a valid class name you could use in that artisan make command. If you want to namespace the component, you can do php artisan make:component \\App\\View\\Components\\Admin\\Newclubform Commented Jun 28, 2021 at 8:43
  • The image is not very helpful. Can you please hover the red underlined line and post the tooltip content (error message) as text instead? Commented Jun 28, 2021 at 8:44
  • php artisan make:component Admin.Newclubform creates all class and view . class is generated by artisan command Commented Jun 28, 2021 at 8:49

1 Answer 1

2

As mentioned by @shaedrich Admin.Newclubform is not a valid class name.

So creating subfolder run command like below

php artisan make:component Admin/NewClubForm

This will create file inside

App\View\Components\Admin\NewClubForm

So your component look like this

<?php

namespace App\View\Components\Admin;

use Illuminate\View\Component;

class NewClubForm extends Component
{
    /**
     * Create a new component instance.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Get the view / contents that represent the component.
     *
     * @return \Illuminate\Contracts\View\View|\Closure|string
     */
    public function render()
    {
        return view('components.admin.new-club-form');
    }
}

then you can access like this

<x-admin.newclubform></x-admin.newclubform>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.