0
votes

Ui folder path=> resources\views\DistributorRegitration.php

< ?php

namespace resources\views;

    class DistributorRegitrationForm
    {

        public  function distributorRegitrationFormHtml(){

            return  'hello'
    }

    }

Controller folder path => App\Http\Controllers\DistributorRegistration.php

< ?php 

namespace App\Http\Controllers;

use App\User;

use App\Http\Controllers\Controller;

use Illuminate\Http\Request;

use resources\views\DistributorRegitrationForm;


class DistributorRegistration  extends Controller

{ 

public function VestigePOS_DistributorRegistration()

{

$distribtutor_reg_form_obj = new DistributorRegitrationForm(); //class in DistributorRegistration.php            
$returned_dist_reg_html = $distribtutor_reg_form_obj->distributorRegitrationFormHtml(); // Function in DistributorRegistrationForm class.

return view($returned_dist_reg_html) ;      
}

}

?>

when i called this controller Fatal error: Class 'resources\views\DistributorRegitrationForm' not found enter image description here

3
Please format your codeJack
have you created the mentioned viewmaytham-ɯɐɥʇʎɐɯ
cahek the screen shot updatedSanjog Mittal
i want to return a function from UI in to controllerSanjog Mittal
method injection from UiSanjog Mittal

3 Answers

0
votes

Rename resources\views\DistributorRegitration.php to the resources\views\DistributorRegitrationForm.php

0
votes

You need to register the file or directory in the autoload classmap section in composer.json in order for the class to be autoloaded.

{
    ...
    "autoload": {
        "classmap": [
            "database",
            "resources/views/"
        ]
    }
    ...
}
0
votes

Rename the view DistributorRegitration.blade.php and move the class inside it in a new file in app folder, for example with name DistributorRegitrationFormClass.php.

Then in the controller change this line:

use resources\views\DistributorRegitrationForm;

to

use App\DistributorRegitrationForm;

and the return view statement to

return view('DistributorRegitration', ['returned_dist_reg_html' => $returned_dist_reg_html]);   

In the view write {{returned_dist_reg_html}} and magically 'hello' will appear.