#51 Festschreiben der Points, Gutschriftenmodul
This commit is contained in:
parent
dfd049aaa9
commit
3f2fbd6d5b
63 changed files with 4610 additions and 971 deletions
99
app/Models/UserCreditItem.php
Normal file
99
app/Models/UserCreditItem.php
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Created by Reliese Model.
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\User;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Class UserCreditItem
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $user_id
|
||||
* @property int|null $user_credit_id
|
||||
* @property float|null $credit
|
||||
* @property string|null $message
|
||||
* @property int $status
|
||||
* @property bool $paid
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
*
|
||||
* @property UserCredit|null $user_credit
|
||||
* @property User $user
|
||||
*
|
||||
* @package App\Models
|
||||
*/
|
||||
class UserCreditItem extends Model
|
||||
{
|
||||
|
||||
|
||||
public static $statusTypes = [
|
||||
1 => 'Provision Shop',
|
||||
2 => 'Provision Team',
|
||||
3 => 'Guthaben hinzugefügt',
|
||||
4 => 'commission ...',
|
||||
];
|
||||
|
||||
public static $statusColors = [
|
||||
0 => 'warning',
|
||||
1 => 'success',
|
||||
2 => 'secondary',
|
||||
3 => 'warning',
|
||||
4 => 'info',
|
||||
10 => 'danger',
|
||||
];
|
||||
|
||||
|
||||
protected $table = 'user_credit_items';
|
||||
|
||||
protected $casts = [
|
||||
'user_id' => 'int',
|
||||
'user_credit_id' => 'int',
|
||||
'credit' => 'float',
|
||||
'status' => 'int',
|
||||
'paid' => 'bool'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'user_credit_id',
|
||||
'credit',
|
||||
'message',
|
||||
'status',
|
||||
'paid'
|
||||
];
|
||||
|
||||
public function user_credit()
|
||||
{
|
||||
return $this->belongsTo(UserCredit::class);
|
||||
}
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
|
||||
public function deleteTime(){
|
||||
$time = '+100 min';
|
||||
if(Carbon::parse($this->created_at)->modify($time)->gt(Carbon::now())){
|
||||
return Carbon::now()->diffInMinutes(Carbon::parse($this->created_at)->modify($time));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getStatusType(){
|
||||
return isset(self::$statusTypes[$this->status]) ? self::$statusTypes[$this->status] : "";
|
||||
}
|
||||
|
||||
public function getStatusColor(){
|
||||
return isset(self::$statusColors[$this->status]) ? self::$statusColors[$this->status] : "default";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue