2016-03-05 00:18:10 +00:00
|
|
|
<?php
|
2016-02-29 15:59:36 +00:00
|
|
|
|
2016-03-05 00:18:10 +00:00
|
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
|
|
use App\Attendize\Utils;
|
2016-02-29 15:59:36 +00:00
|
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
|
|
2016-03-05 00:18:10 +00:00
|
|
|
class Account extends MyBaseModel
|
|
|
|
|
{
|
2016-02-29 15:59:36 +00:00
|
|
|
use SoftDeletes;
|
2016-03-05 00:18:10 +00:00
|
|
|
|
2016-03-14 16:37:38 +00:00
|
|
|
/**
|
|
|
|
|
* The validation rules
|
|
|
|
|
*
|
|
|
|
|
* @var array $rules
|
|
|
|
|
*/
|
2016-02-29 15:59:36 +00:00
|
|
|
protected $rules = [
|
|
|
|
|
'first_name' => ['required'],
|
2016-03-05 00:18:10 +00:00
|
|
|
'last_name' => ['required'],
|
|
|
|
|
'email' => ['required', 'email'],
|
2016-02-29 15:59:36 +00:00
|
|
|
];
|
2016-03-05 00:18:10 +00:00
|
|
|
|
2016-03-14 16:37:38 +00:00
|
|
|
/**
|
|
|
|
|
* The attributes that should be mutated to dates.
|
|
|
|
|
*
|
|
|
|
|
* @var array $dates
|
|
|
|
|
*/
|
2016-03-09 22:05:39 +00:00
|
|
|
public $dates = ['deleted_at'];
|
|
|
|
|
|
2016-03-14 16:37:38 +00:00
|
|
|
/**
|
|
|
|
|
* The validation error messages.
|
|
|
|
|
*
|
|
|
|
|
* @var array $messages
|
|
|
|
|
*/
|
2016-02-29 15:59:36 +00:00
|
|
|
protected $messages = [];
|
2016-03-05 00:18:10 +00:00
|
|
|
|
2016-03-14 16:37:38 +00:00
|
|
|
/**
|
|
|
|
|
* The attributes that are mass assignable.
|
|
|
|
|
*
|
|
|
|
|
* @var array $fillable
|
|
|
|
|
*/
|
2016-03-09 22:05:39 +00:00
|
|
|
protected $fillable = [
|
|
|
|
|
'first_name',
|
|
|
|
|
'last_name',
|
|
|
|
|
'email',
|
|
|
|
|
'timezone_id',
|
|
|
|
|
'date_format_id',
|
|
|
|
|
'datetime_format_id',
|
|
|
|
|
'currency_id',
|
|
|
|
|
'name',
|
|
|
|
|
'last_ip',
|
|
|
|
|
'last_login_date',
|
|
|
|
|
'address1',
|
|
|
|
|
'address2',
|
|
|
|
|
'city',
|
|
|
|
|
'state',
|
|
|
|
|
'postal_code',
|
|
|
|
|
'country_id',
|
|
|
|
|
'email_footer',
|
|
|
|
|
'is_active',
|
|
|
|
|
'is_banned',
|
|
|
|
|
'is_beta',
|
|
|
|
|
'stripe_access_token',
|
|
|
|
|
'stripe_refresh_token',
|
|
|
|
|
'stripe_secret_key',
|
|
|
|
|
'stripe_publishable_key',
|
|
|
|
|
'stripe_data_raw'
|
|
|
|
|
];
|
|
|
|
|
|
2016-03-14 16:37:38 +00:00
|
|
|
/**
|
|
|
|
|
* The users associated with the account.
|
|
|
|
|
*
|
|
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
|
|
|
|
*/
|
2016-03-05 00:18:10 +00:00
|
|
|
public function users()
|
|
|
|
|
{
|
2016-02-29 15:59:36 +00:00
|
|
|
return $this->hasMany('\App\Models\User');
|
|
|
|
|
}
|
2016-03-05 00:18:10 +00:00
|
|
|
|
2016-03-14 16:37:38 +00:00
|
|
|
/**
|
|
|
|
|
* The orders associated with the account.
|
|
|
|
|
*
|
|
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
|
|
|
|
*/
|
2016-03-05 00:18:10 +00:00
|
|
|
public function orders()
|
|
|
|
|
{
|
2016-02-29 15:59:36 +00:00
|
|
|
return $this->hasMany('\App\Models\Order');
|
|
|
|
|
}
|
2016-03-05 00:18:10 +00:00
|
|
|
|
2016-03-14 16:37:38 +00:00
|
|
|
/**
|
|
|
|
|
* The currency associated with the account.
|
|
|
|
|
*
|
|
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\HasOne
|
|
|
|
|
*/
|
2016-03-05 00:18:10 +00:00
|
|
|
public function currency()
|
|
|
|
|
{
|
2016-02-29 15:59:36 +00:00
|
|
|
return $this->hasOne('\App\Models\Currency');
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-14 16:37:38 +00:00
|
|
|
/**
|
|
|
|
|
* Get the stripe api key.
|
|
|
|
|
*
|
|
|
|
|
* @return \Illuminate\Support\Collection|mixed|static
|
|
|
|
|
*/
|
2016-03-05 00:18:10 +00:00
|
|
|
public function getStripeApiKeyAttribute()
|
|
|
|
|
{
|
|
|
|
|
if (Utils::isAttendize()) {
|
2016-02-29 15:59:36 +00:00
|
|
|
return $this->stripe_access_token;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $this->stripe_secret_key;
|
|
|
|
|
}
|
|
|
|
|
}
|