I am using Laravel and I have just moved my code that is working locally into Live and am getting the exception below within my 'User' controller:
Unhandled Exception
Message:
Using $this when not in object context
The strange thing is, that this IS a class and works locally fine so I don't expect the solution to be using the static notation. It's only when I promote this to Live that I get this error. Could it be that something in the Laravel core that is missing from Live that is not loading the controller class properly?
Has anyone experienced this after promoting their code to Live? any ideas?
UPDATED: snippet of code where error is occuring. remember this code works locally so i believe something is missing rather than this code needs to be changed to fix this issue.
class User_Controller extends Base_Controller {
...
public function action_register() {
...
if ($user) {
//Create the Contact
DB::transaction(function() use ($user_id) {
$org = $this->create_org($user_id); //failing on this line with exception. btw $user is created fine
$this->create_contact($org->id);
$this->create_address($org->id);
});
private function create_org($user_id) {
$result = Org_type::where('name','=',$_POST['org_type'])->first();
$org = Org::Create(
array(
'name' => $_POST['org_name'],
'user_id' => $user_id,
'org_type_id' => $result->id,
)
);
return $org;
}
...