<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Log extends Model
{
    public function user()
    {
        return $this->belongsTo(User::class);
    }

    public static function saveLog($action, $user = "default")
    {
        $log = new Log;

        if ($user == "default") {
            $user = \Auth::User()->id;
        }
        
        $log->action = $action;
        $log->user_id = $user;

        $log->save();
    }
}
