2
votes

I created 'Log' class in app/models :

class Log extends Eloquent {

    public function user() {
        return $this->belongsTo('user');
    }

}

When i try to save log object in my controller i got this error (Call to undefined method Illuminate\Support\Facades\Log::save() ) I thik because in (app/config/app) in providers laravel define Log class => 'Log'=> 'Illuminate\Support\Facades\Log',.

How can i resolve this problem without change class name ?

1

1 Answers

1
votes

Yes the problem is indeed a conflict with the Log facade alias. To fix it use namespaces:

<?php namespace YourApp;

class Log extends Eloquent {

    public function user() {
        return $this->belongsTo('user');
    }

}

And then you can use your class like so:

$log = new YourApp\Log();

You could of course rename the alias name, but namespacing your classes is a much better approach.