64 lines
1.5 KiB
PHP
64 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App;
|
|
|
|
use Illuminate\Notifications\Notifiable;
|
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
|
use App\Season;
|
|
use App\Payment;
|
|
|
|
class User extends Authenticatable
|
|
{
|
|
use Notifiable;
|
|
|
|
/**
|
|
* The attributes that are mass assignable.
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $fillable = [
|
|
'name', 'email', 'password',
|
|
];
|
|
|
|
/**
|
|
* The attributes that should be hidden for arrays.
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $hidden = [
|
|
'password', 'remember_token',
|
|
];
|
|
|
|
|
|
// Only the current season.
|
|
public static function is_season_paid($user_id) {
|
|
$retval="Ja";
|
|
if (User::payment_date($user_id, Season::getCurrent()->id)==null) { $retval="Nein"; }
|
|
|
|
return $retval;
|
|
}
|
|
|
|
public static function payment_date($user_id,$season_id) {
|
|
$season = Season::getCurrent();
|
|
if ($season) {
|
|
$payment = Payment::where([
|
|
['user_id', '=', $user_id],
|
|
['season_id', '=', $season->id]
|
|
])->first();
|
|
if ($payment) {
|
|
if ($payment->paid_date) {
|
|
return $payment->paid_date;
|
|
}
|
|
} else {
|
|
$payment= Payment::create([
|
|
'user_id' => $user_id,
|
|
'season_id'=> $season->id,
|
|
'paid_date'=> null
|
|
]);
|
|
$payment->save();
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
}
|