I want to set a public variable so I can use it in different controllers. I tried this but it is not successful.
class HomeController extends Controller
{
public $TravelId;
public function __construct()
{
$this->TravelId=0;
}
}
then I used the same variable in another contorller
class HomeController extends Controller
{
public function index($cus_id)
{
//unique key for each user
$this->TravelId = $cus_id;
}
}
class Helper
{public static function Update($id){
$user_idd = auth()->user()->id;
$user = User::find($user_idd);
if ($user->isAdmin ==1){
$user_id = $this->TravelId;
self::$staticTravelId = $user_id;
}
else{
$user_id = $user_idd;
}
I want to use the user_id Inside the public variable here
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire