Nice Day All,
I'm trying to send a variable to the model to be used in all the function without passing it as a parameter to all function, here is what I have do, but it doesn't work, anyone Can figure out the problem?
SomethingController.php
public function store(){
$user_value = \Request::input('value'); // get value from user
$somethingObj = new \App\Something(['user_value' => $user_value ]);
$somethingObj->doSomething();
}
Something.php
public $value;
public function __constructor($attributes){
$this->value = $attributes['user_value'];
}
public function doSomething(){
if($this->value){
// this is not working , $value not working also $this->$value didn't work too
doSomething();
}else{
doOtherThing();
}
}