mirror of
				https://github.com/crater-invoice/crater.git
				synced 2025-10-31 05:31:10 -04:00 
			
		
		
		
	build version 400
This commit is contained in:
		
							
								
								
									
										45
									
								
								app/Models/Company.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								app/Models/Company.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,45 @@ | ||||
| <?php | ||||
| namespace Crater\Models; | ||||
|  | ||||
| use Crater\Models\Address; | ||||
| use Illuminate\Database\Eloquent\Model; | ||||
| use Crater\Models\User; | ||||
| use Crater\Models\CompanySetting; | ||||
| use Spatie\MediaLibrary\HasMedia; | ||||
| use Spatie\MediaLibrary\InteractsWithMedia; | ||||
| use Illuminate\Database\Eloquent\Factories\HasFactory; | ||||
|  | ||||
| class Company extends Model implements HasMedia | ||||
| { | ||||
|     use InteractsWithMedia; | ||||
|  | ||||
|     use HasFactory; | ||||
|  | ||||
|     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); | ||||
|     } | ||||
|  | ||||
|     public function address() | ||||
|     { | ||||
|         return $this->hasOne(Address::class); | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user