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

V-CHHETRI
  • 63
  • 4
  • 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` – shaedrich Jun 28 '21 at 08: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? – shaedrich Jun 28 '21 at 08:44
  • php artisan make:component Admin.Newclubform creates all class and view . class is generated by artisan command – V-CHHETRI Jun 28 '21 at 08:49

1 Answers1

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>
John Lobo
  • 14,355
  • 2
  • 10
  • 20