public function Purge() { $retention = Settings::get('retention', 30); $retentionDate = date('Y-m-d H:i:s', strtotime('-' . $retention . ' day')); $protectRows = MessageMax::lists('row_id'); Message::whereNotIn('id', $protectRows)->where('sent_at', '<', $retentionDate)->where('read', 1)->delete(); }