php - Laravel - using a class in the same folder -


i looking have separate class handle validation of new user.

folder structure is:

| app   | website     | usercreator        - usercreator.php        - uservalidation.php 

in usercreator file trying use method in uservalidation class this:

public function createuser($input) {     uservalidation::validate($input); } 

however getting this:

class 'website\usercreator\uservalidation' not found 

this validation class:

<?php 

use illuminate\support\facades\validator validator;

class uservalidation {    public static $rules = array(     'first_name' => 'required',     'email_address' => 'unique:users'   );    public static $messages = [   ];    /**    * validate new user input    * @param  $input   */   public function validate($input) {     // validate   }  } 

do need instantiate class this? in controller?

my controller is:

use website\usercreator\usercreator usercreator;  class usercreatorcontroller extends basecontroller {    protected $usercreator;    public function __construct(usercreator $usercreator){     $this->usercreator = $usercreator;   }    public function addnewuser() {     return $this->usercreator->createuser($input);   }   } 

because classes in same folder, didnt think needed namespace validation 1 / define use in usercreator?

where going wrong?

try adding namespace... php doesn't care directory file in, make sure specify namespace website\usercreator;. if does't work, what's autoloader like?


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -