| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- <?php
- namespace App;
- use App\Enums\AruStatuses;
- use App\Traits\DateTimeTrait;
- use App\Traits\SoftDeleteTrait;
- use Exception;
- /**
- * Class Location
- * @property int $id
- * @property int $customer_id
- * @property int $address_id
- * @property string $name
- * @property string $phone
- * @property string $fax
- * @property string $email
- * @property string $contact_name
- * @property string $contact_phone
- * @property string $contact_email
- */
- class Location extends Model {
- protected static $table = "location";
- protected static $idField = "id";
- protected static $fillableFields = [
- "customer_id", "address_id",
- "name", "phone", "fax", "email",
- "contact_name", "contact_phone", "contact_email",
- "dts_created", "dts_updated", "dts_deleted"
- ];
- use DateTimeTrait;
- use SoftDeleteTrait;
- /**
- * @return Customer
- * @throws Exception
- */
- public function getCustomer(): Customer {
- return Customer::get($this->customer_id);
- }
- /**
- * @return Address
- * @throws Exception
- */
- public function getAddress(): Address {
- $address = Address::get($this->address_id);
- return $address ?: new Address();
- }
- public function getSlug(): string {
- return Util::slug("$this->name $this->id");
- }
- /**
- * @return string
- * @throws Exception
- */
- public function getUrl(): string {
- return sprintf("/locations/%s/update", $this->getSlug());
- }
- /**
- * @return string
- * @throws Exception
- */
- public function getDisplayName(): string {
- $customer = $this->getCustomer();
- return sprintf("%s - %s", $customer->name, $this->name);
- }
- }
|