Added ads, adblocker, fixed scrollbar, fixed route and asset links of blog
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
@@ -18,4 +19,17 @@ class Log extends Model
|
||||
'ip',
|
||||
'email',
|
||||
];
|
||||
|
||||
public static function deleteLogsFromDB() {
|
||||
$cutoff = Carbon::now('UTC')->subMonths(3)->toDateTimeString();
|
||||
$count = count(self::where('created_at', '<', $cutoff)
|
||||
->orderBy('created_at', 'desc')
|
||||
->get());
|
||||
|
||||
if ($count > 0) {
|
||||
self::where('created_at', '<', $cutoff)->delete();
|
||||
return "$count old log(s) deleted from the database.";
|
||||
}
|
||||
return "No logs older than 3 months found.";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user