first commit
This commit is contained in:
37
app/Models/Document.php
Normal file
37
app/Models/Document.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class Document extends Model
|
||||
{
|
||||
protected $table = 'document';
|
||||
|
||||
use HasFactory;
|
||||
|
||||
const STATUS_NOT_APPLIED = 0;
|
||||
const STATUS_APPLIED = 1;
|
||||
const TYPE_TO = 0;
|
||||
const TYPE_FROM = 1;
|
||||
protected $fillable = ['type', 'date', 'status'];
|
||||
|
||||
public function products(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Product::class);
|
||||
}
|
||||
|
||||
public static function getTitlesOfTypes()
|
||||
{
|
||||
return [self::TYPE_TO => 'Поступление', self::TYPE_FROM => 'Расход'];
|
||||
}
|
||||
|
||||
public function documentProducts(): HasMany
|
||||
{
|
||||
return $this->hasMany(DocumentProduct::class);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user