37 lines
941 B
PHP
37 lines
941 B
PHP
<?php
|
|
|
|
namespace App;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use App\User;
|
|
|
|
class Payment extends Model
|
|
{
|
|
protected $fillable = [
|
|
'season_id', 'user_id', 'paid_date'
|
|
];
|
|
|
|
public static function set_payment_date($user_id,$season_id,$paid_date) {
|
|
|
|
$payment = Payment::where([
|
|
['user_id', '=', $user_id],
|
|
['season_id', '=', $season_id]
|
|
])->first();
|
|
|
|
if (!$payment) {
|
|
$payment= Payment::create([
|
|
'user_id' => $user_id,
|
|
'season_id'=> $season_id,
|
|
'paid_date'=> $paid_date ? User::toDBDate($paid_date):null
|
|
]);
|
|
|
|
} else {
|
|
$payment->user_id = $user_id;
|
|
$payment->season_id = $season_id;
|
|
$payment->paid_date = $paid_date ? User::toDBDate($paid_date):null;
|
|
}
|
|
|
|
$payment->save();
|
|
|
|
}
|
|
}
|