| Server IP : 103.161.17.216 / Your IP : 216.73.216.1 Web Server : nginx/1.18.0 System : Linux tipsysaigoncharming 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 User : www-data ( 33) PHP Version : 7.4.3-4ubuntu2.29 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /var/www/app.ansachsongkhoe.net/app/ |
Upload File : |
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Business extends Model
{
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'business';
/**
* The attributes that aren't mass assignable.
*
* @var array
*/
protected $guarded = ['id', 'woocommerce_api_settings'];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = ['woocommerce_api_settings'];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [
'ref_no_prefixes' => 'array',
'enabled_modules' => 'array',
'email_settings' => 'array',
'sms_settings' => 'array',
'common_settings' => 'array',
'weighing_scale_setting' => 'array'
];
/**
* Returns the date formats
*/
public static function date_formats()
{
return [
'd-m-Y' => 'dd-mm-yyyy',
'm-d-Y' => 'mm-dd-yyyy',
'd/m/Y' => 'dd/mm/yyyy',
'm/d/Y' => 'mm/dd/yyyy'
];
}
/**
* Get the owner details
*/
public function owner()
{
return $this->hasOne(\App\User::class, 'id', 'owner_id');
}
/**
* Get the Business currency.
*/
public function currency()
{
return $this->belongsTo(\App\Currency::class);
}
/**
* Get the Business currency.
*/
public function locations()
{
return $this->hasMany(\App\BusinessLocation::class);
}
/**
* Get the Business printers.
*/
public function printers()
{
return $this->hasMany(\App\Printer::class);
}
/**
* Get the Business subscriptions.
*/
public function subscriptions()
{
return $this->hasMany('\Modules\Superadmin\Entities\Subscription');
}
/**
* Creates a new business based on the input provided.
*
* @return object
*/
public static function create_business($details)
{
$business = Business::create($details);
return $business;
}
/**
* Updates a business based on the input provided.
* @param int $business_id
* @param array $details
*
* @return object
*/
public static function update_business($business_id, $details)
{
if (!empty($details)) {
Business::where('id', $business_id)
->update($details);
}
}
public function getBusinessAddressAttribute()
{
$location = $this->locations->first();
$address = $location->landmark . ', ' .$location->city .
', ' . $location->state . '<br>' . $location->country . ', ' . $location->zip_code;
return $address;
}
}