[WIP] Import Plans
This commit is contained in:
45
app/Models/Corporate.php
Normal file
45
app/Models/Corporate.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\Blameable;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Corporate extends Model
|
||||
{
|
||||
use HasFactory, SoftDeletes, Blameable;
|
||||
|
||||
protected $fillable = [
|
||||
'code',
|
||||
'name',
|
||||
'welcome_message',
|
||||
'help_text',
|
||||
'active'
|
||||
];
|
||||
|
||||
public function imports()
|
||||
{
|
||||
return $this->morphMany(ImportLog::class, 'importable');
|
||||
}
|
||||
|
||||
public function files()
|
||||
{
|
||||
return $this->morphMany(File::class, 'fileable');
|
||||
}
|
||||
|
||||
public function policies()
|
||||
{
|
||||
return $this->hasMany(CorporatePolicy::class);
|
||||
}
|
||||
|
||||
public function currentPolicy()
|
||||
{
|
||||
return $this->hasOne(CorporatePolicy::class)
|
||||
// ->where('start', '<=', now())
|
||||
// ->where('end', '>=', now())
|
||||
->where('active', true)
|
||||
->latestOfMany();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user