20-02-2026
This commit is contained in:
parent
a8b395e20d
commit
a00c42e770
252 changed files with 28785 additions and 8907 deletions
|
|
@ -2,20 +2,16 @@
|
|||
|
||||
namespace App\Repositories;
|
||||
|
||||
use Carbon;
|
||||
use App\Models\UserAbo;
|
||||
use App\Services\AboHelper;
|
||||
|
||||
class AboRepository extends BaseRepository
|
||||
{
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
//$this->model = $model;
|
||||
// $this->model = $model;
|
||||
}
|
||||
|
||||
|
||||
public function setModel(UserAbo $model)
|
||||
{
|
||||
$this->model = $model;
|
||||
|
|
@ -28,14 +24,17 @@ class AboRepository extends BaseRepository
|
|||
if ($this->validate($data)) {
|
||||
$this->updateStatus($data);
|
||||
$this->model->abo_interval = $data['abo_interval'];
|
||||
$this->model->next_date = AboHelper::setNextDate(now(), $data['abo_interval']);
|
||||
$this->model->next_date = AboHelper::setNextDate(now(), $data['abo_interval']);
|
||||
$this->model->save();
|
||||
\Session()->flash('alert-success', 'Einstellungen gespeichert');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -50,52 +49,57 @@ class AboRepository extends BaseRepository
|
|||
$this->model->active = false;
|
||||
$this->model->cancel_date = now();
|
||||
$this->model->save();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$active = (isset($data['abo_is_active']) && $data['abo_is_active']) ? true : false;
|
||||
//if status is active and active is false, set status to inactive
|
||||
if ($this->model->active && !$active) {
|
||||
if ($this->model->status == 2) { //okay
|
||||
$this->model->status = 6; //inactive
|
||||
// if status is active and active is false, set status to inactive
|
||||
if ($this->model->active && ! $active) {
|
||||
if ($this->model->status == 2) { // okay
|
||||
$this->model->status = 6; // inactive
|
||||
$this->model->active = false;
|
||||
$this->model->save();
|
||||
}
|
||||
}
|
||||
if (!$this->model->active && $active) {
|
||||
if ($this->model->status = 6) { //inactive
|
||||
$this->model->status = 2; //okay
|
||||
if (! $this->model->active && $active) {
|
||||
if ($this->model->status = 6) { // inactive
|
||||
$this->model->status = 2; // okay
|
||||
$this->model->active = true;
|
||||
$this->model->save();
|
||||
}
|
||||
}
|
||||
$this->model->active = $active;
|
||||
return;
|
||||
}
|
||||
|
||||
private function validate($data)
|
||||
{
|
||||
if ($data['view'] !== 'admin') {
|
||||
if ($data['view'] !== 'admin' && $data['view'] !== 'portal') {
|
||||
if ($this->model->is_for === 'me' && $this->model->user_id !== \Auth::user()->id) {
|
||||
\Session()->flash('alert-error', 'Unauthorized action. User ID does not match.');
|
||||
|
||||
return false;
|
||||
}
|
||||
if ($this->model->is_for === 'ot' && $this->model->member_id !== \Auth::user()->id) {
|
||||
\Session()->flash('alert-error', 'Unauthorized action. User ID does not match.');
|
||||
|
||||
return false;
|
||||
}
|
||||
if ($data['view'] === 'me' && $this->model->is_for !== 'me') {
|
||||
\Session()->flash('alert-error', 'Unauthorized action. Is not for me');
|
||||
|
||||
return false;
|
||||
}
|
||||
if ($data['view'] === 'ot' && $this->model->is_for !== 'ot') {
|
||||
\Session()->flash('alert-error', 'Unauthorized action. Is not your customer');
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!in_array($data['abo_interval'], \App\Models\UserAbo::$aboDeliveryDays)) {
|
||||
//to check if user is not admin
|
||||
if (! in_array($data['abo_interval'], \App\Models\UserAbo::$aboDeliveryDays)) {
|
||||
// to check if user is not admin
|
||||
\Session()->flash('alert-error', __('abo.error_abo_interval'));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -104,8 +108,9 @@ class AboRepository extends BaseRepository
|
|||
// da setNextDate das nächste Ausführungsdatum sonst auf den nächsten Monat setzt und dieser Monat übersprungen wird.
|
||||
$executedThisMonth = $this->model->last_date && \Carbon\Carbon::parse($this->model->last_date)->isCurrentMonth();
|
||||
|
||||
if (!$executedThisMonth && $data['abo_interval'] <= now()->day) {
|
||||
if (! $executedThisMonth && $data['abo_interval'] <= now()->day) {
|
||||
\Session()->flash('alert-error', __('abo.error_abo_interval_in_the_past'));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue