initial commit
This commit is contained in:
42
app/Models/Sale.php
Normal file
42
app/Models/Sale.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Sale extends Model
|
||||
{
|
||||
/** @use HasFactory<\Database\Factories\SaleFactory> */
|
||||
use HasFactory;
|
||||
|
||||
protected $appends = [
|
||||
"address",
|
||||
];
|
||||
|
||||
public function address(): Attribute
|
||||
{
|
||||
return Attribute::get(function () {
|
||||
$parts = [
|
||||
$this->street,
|
||||
$this->city,
|
||||
$this->state_province,
|
||||
$this->zip_postal_code,
|
||||
];
|
||||
|
||||
return implode(', ', array_filter($parts));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public function market()
|
||||
{
|
||||
return $this->belongsTo(Market::class);
|
||||
}
|
||||
|
||||
public function subMarket()
|
||||
{
|
||||
return $this->belongsTo(SubMarket::class);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user