mirror of
https://github.com/crater-invoice/crater.git
synced 2025-10-28 04:01:10 -04:00
init crater
This commit is contained in:
36
app/Company.php
Normal file
36
app/Company.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
namespace Laraspace;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Laraspace\User;
|
||||
use Laraspace\CompanySetting;
|
||||
use Spatie\MediaLibrary\HasMedia\HasMedia;
|
||||
use Spatie\MediaLibrary\HasMedia\HasMediaTrait;
|
||||
|
||||
class Company extends Model implements HasMedia
|
||||
{
|
||||
use HasMediaTrait;
|
||||
|
||||
protected $fillable = ['name', 'logo', 'unique_hash'];
|
||||
|
||||
protected $appends=['logo'];
|
||||
|
||||
public function getLogoAttribute()
|
||||
{
|
||||
$logo = $this->getMedia('logo')->first();
|
||||
if ($logo) {
|
||||
return asset($logo->getUrl());
|
||||
}
|
||||
return ;
|
||||
}
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->hasOne(User::class);
|
||||
}
|
||||
|
||||
public function settings()
|
||||
{
|
||||
return $this->hasMany(CompanySetting::class);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user