I am using Spatie activity log package. Within my controller, I am trying to pass the model name but I get the on my question's title.

See my Model below:

class Project extends Model
{
    //
    use SoftDeletes;
    protected $softDelete = true;

    protected static $logAttibutes = ['projectname','duedate','team_id','assignee_id',
        ,'projecttype_id'];
    public static $logName = 'project';
    public function getDescriptionForEvent(string $eventName): string
    {
        return "You have {$eventName} project" ;
    }

The event logging for viewing a list happens in the controller. As shown below:

public function index()
{
    //
    $projects = Project::all();

    activity()
        ->useLog('Projects')
        ->withProperties(['type'=>'view project list'])
        ->performedOn(Project::class)
        ->log('viewed the project list');

    return view('projects.index',['projects'=>$projects]);
}

On performedOn, I also tried:

->performedOn('App/Project')

The documentation says

->performedOn($someContentModel)

This is just a variable and I know a variable needs to be populated with some data, but I think I'm struggling to understand the format of that data

1

There are 1 best solutions below

1
On BEST ANSWER

Can you try this :

$project = new Project();
--
$activity()
->performedOn($project)

That means use the object of project as argument which we can also call, the instance of model.