Rechnungen + Gutschriften
This commit is contained in:
parent
39ef16686a
commit
35ae3da244
33 changed files with 2834 additions and 34 deletions
116
app/Models/UserCredit.php
Normal file
116
app/Models/UserCredit.php
Normal file
|
|
@ -0,0 +1,116 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Created by Reliese Model.
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
|
||||
/**
|
||||
* Class UserCredit
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $auth_user_id
|
||||
* @property float|null $net
|
||||
* @property float|null $tax_rate
|
||||
* @property float|null $tax
|
||||
* @property float|null $total
|
||||
* @property string|null $credit
|
||||
* @property string|null $user_margins
|
||||
* @property bool $paid_out
|
||||
* @property bool $cancellation
|
||||
* @property int $status
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property User $user
|
||||
* @package App\Models
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserCredit newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserCredit newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserCredit query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserCredit whereAuthUserId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserCredit whereCancellation($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserCredit whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserCredit whereCredit($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserCredit whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserCredit whereNet($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserCredit wherePaidOut($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserCredit whereStatus($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserCredit whereTax($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserCredit whereTaxRate($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserCredit whereTotal($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserCredit whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserCredit whereUserMargins($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class UserCredit extends Model
|
||||
{
|
||||
protected $table = 'user_credits';
|
||||
|
||||
protected $casts = [
|
||||
'auth_user_id' => 'int',
|
||||
'net' => 'float',
|
||||
'tax_rate' => 'float',
|
||||
'tax' => 'float',
|
||||
'total' => 'float',
|
||||
'paid_out' => 'bool',
|
||||
'cancellation' => 'bool',
|
||||
'status' => 'int',
|
||||
'credit' => 'array',
|
||||
'user_margins' => 'object'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'auth_user_id',
|
||||
'net',
|
||||
'tax_rate',
|
||||
'tax',
|
||||
'total',
|
||||
'date',
|
||||
'credit',
|
||||
'user_margins',
|
||||
'paid_out',
|
||||
'cancellation',
|
||||
'status'
|
||||
];
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(\App\User::class, 'auth_user_id');
|
||||
}
|
||||
|
||||
public function getDateAttribute($value)
|
||||
{
|
||||
if(!$value){
|
||||
return "";
|
||||
}
|
||||
return Carbon::parse($value)->format(\Util::formatDateDB());
|
||||
}
|
||||
|
||||
|
||||
public function setDateAttribute( $value ) {
|
||||
$this->attributes['date'] = isset($value) ? (new Carbon($value))->format('Y-m-d') : NULL;
|
||||
}
|
||||
public function getDateRaw(){
|
||||
return isset($this->attributes['date']) ? $this->attributes['date'] : NULL;
|
||||
}
|
||||
|
||||
public function getFormattedTax()
|
||||
{
|
||||
return formatNumber($this->attributes['tax']);
|
||||
}
|
||||
|
||||
public function getFormattedNet()
|
||||
{
|
||||
return formatNumber($this->attributes['net']);
|
||||
}
|
||||
|
||||
public function getFormattedTotal()
|
||||
{
|
||||
return formatNumber($this->attributes['total']);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue