Closed nehulagr closed 8 years ago
Did you import the Activity
-facade at the top of your file?
use Activity;
No its not allowing me to import two files. I have already import
use Spatie\Activitylog\Models\Activity;
What should i do?
Here is how my full controller looks like...
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Auth;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use Spatie\Activitylog\Models\Activity;
//use Activity;
class LogsController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$latestActivities = Activity::with('user')->latest()->get();
return view('logs.logs')->with('logs', $latestActivities);
}
public function headerLogs()
{
$latestActivities = Activity::with('user')->latest()->limit(10)->get();
return view('layouts.header')->with('logs', $latestActivities);
}
public function clearlog(){
Activity::cleanLog();
Activity::log('Logs cleared By : '.Auth::user()->name);
\Session::flash('success', 'Logs deleted successfully');
return redirect('logs');
}
}
You'll need to rename one of your imports with the as
keyword.
use Activity;
use Spatie\Activitylog\Models\Activity as ActivityModel;
Thank you for such a nice module. It works great. Its simple and working.
I just need to know why Activity::cleanLog(); is not working? Its showing this error
I am just using it normally, like below i have a controller with name LogsController and i have used
use Spatie\Activitylog\Models\Activity;
in which i have just 2 functions as below:I have defined a route for this:
I dont know where i am making mistake. Please help me get this thing straight. I am new to laravel.
Thank you!