Update Log aktivitas
This commit is contained in:
+11
-1
@@ -11,13 +11,16 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Laravel\Sanctum\HasApiTokens;
|
||||
use App\Models\Concerns\CatatAktivitas;
|
||||
|
||||
use App\Models\Konfigurasi\KoordinatorKomoditas;
|
||||
use App\Models\Pertanian\Petani;
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
use HasFactory, Notifiable, HasApiTokens, SoftDeletes;
|
||||
use HasFactory, Notifiable, HasApiTokens, SoftDeletes, CatatAktivitas;
|
||||
|
||||
protected string $labelAktivitas = 'Pengguna';
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
@@ -63,6 +66,13 @@ class User extends Authenticatable
|
||||
|
||||
$user->koordinatorKomoditas()->get()->each->delete();
|
||||
});
|
||||
|
||||
// Log ganti password (tanpa isi)
|
||||
static::updated(function (User $user) {
|
||||
if ($user->wasChanged('password')) {
|
||||
activity('user')->performedOn($user)->event('password')->log('Password diubah');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function koordinatorKomoditas(): HasMany
|
||||
|
||||
Reference in New Issue
Block a user