-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #166 from bildvitta/develop
Develop to Master
- Loading branch information
Showing
10 changed files
with
476 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
namespace BildVitta\Hub\Models; | ||
|
||
use BildVitta\Hub\Traits\UsesHubDB; | ||
use Illuminate\Database\Eloquent\Model; | ||
use Illuminate\Database\Eloquent\Relations\HasMany; | ||
use Illuminate\Database\Eloquent\SoftDeletes; | ||
use Ramsey\Uuid\Uuid; | ||
|
||
class Brand extends Model | ||
{ | ||
use SoftDeletes; | ||
use UsesHubDB; | ||
|
||
protected $connection = 'iss-sdk'; | ||
|
||
protected $table = 'brands'; | ||
|
||
protected $guard_name = 'web'; | ||
|
||
public static function boot() | ||
{ | ||
parent::boot(); | ||
|
||
self::creating(function ($model) { | ||
$model->uuid = (string) Uuid::uuid4(); | ||
}); | ||
} | ||
|
||
public function getRouteKeyName() | ||
{ | ||
return 'uuid'; | ||
} | ||
|
||
// | ||
|
||
public function companies(): HasMany | ||
{ | ||
return $this->hasMany(Company::class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?php | ||
|
||
namespace BildVitta\Hub\Models; | ||
|
||
use BildVitta\Hub\Traits\UsesHubDB; | ||
use Illuminate\Database\Eloquent\Model; | ||
use Illuminate\Database\Eloquent\Relations\BelongsTo; | ||
use Illuminate\Database\Eloquent\Relations\HasMany; | ||
use Illuminate\Database\Eloquent\Relations\HasManyThrough; | ||
use Illuminate\Database\Eloquent\SoftDeletes; | ||
use Ramsey\Uuid\Uuid; | ||
|
||
class Company extends Model | ||
{ | ||
use SoftDeletes; | ||
use UsesHubDB; | ||
|
||
protected $connection = 'iss-sdk'; | ||
|
||
protected $table = 'companies'; | ||
|
||
protected $guard_name = 'web'; | ||
|
||
public static function boot() | ||
{ | ||
parent::boot(); | ||
|
||
self::creating(function ($model) { | ||
$model->uuid = (string) Uuid::uuid4(); | ||
}); | ||
} | ||
|
||
public function getRouteKeyName() | ||
{ | ||
return 'uuid'; | ||
} | ||
|
||
// | ||
|
||
public function users(): HasManyThrough | ||
{ | ||
return $this->hasManyThrough( | ||
User::class, | ||
UserCompany::class, | ||
'company_id', | ||
'id', | ||
'id', | ||
'user_id' | ||
); | ||
} | ||
|
||
public function main_company(): BelongsTo | ||
{ | ||
return $this->belongsTo(Company::class, 'main_company_id', 'id'); | ||
} | ||
|
||
public function sub_companies(): HasMany | ||
{ | ||
return $this->hasMany(Company::class, 'main_company_id', 'id'); | ||
} | ||
|
||
public function user_companies(): HasMany | ||
{ | ||
return $this->hasMany(UserCompany::class, 'company_id', 'id'); | ||
} | ||
|
||
public function brand(): BelongsTo | ||
{ | ||
return $this->belongsTo(Brand::class, 'brand_id', 'id'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
namespace BildVitta\Hub\Models; | ||
|
||
use BildVitta\Hub\Traits\UsesHubDB; | ||
use Illuminate\Database\Eloquent\Model; | ||
use Illuminate\Database\Eloquent\Relations\BelongsTo; | ||
use Illuminate\Database\Eloquent\Relations\HasMany; | ||
use Illuminate\Database\Eloquent\SoftDeletes; | ||
use Ramsey\Uuid\Uuid; | ||
|
||
class Position extends Model | ||
{ | ||
use SoftDeletes; | ||
use UsesHubDB; | ||
|
||
protected $connection = 'iss-sdk'; | ||
|
||
protected $table = 'positions'; | ||
|
||
protected $guard_name = 'web'; | ||
|
||
public static function boot() | ||
{ | ||
parent::boot(); | ||
|
||
self::creating(function ($model) { | ||
$model->uuid = (string) Uuid::uuid4(); | ||
}); | ||
} | ||
|
||
public function getRouteKeyName() | ||
{ | ||
return 'uuid'; | ||
} | ||
|
||
// | ||
|
||
public function company(): BelongsTo | ||
{ | ||
return $this->belongsTo(Company::class); | ||
} | ||
|
||
public function parent_position(): BelongsTo | ||
{ | ||
return $this->belongsTo(Position::class, 'parent_position_id', 'id'); | ||
} | ||
|
||
public function user_companies(): HasMany | ||
{ | ||
return $this->hasMany(UserCompany::class, 'position_id', 'id'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
|
||
namespace BildVitta\Hub\Models; | ||
|
||
use BildVitta\Hub\Traits\UsesHubDB; | ||
use Illuminate\Database\Eloquent\Model; | ||
use Illuminate\Database\Eloquent\Relations\BelongsTo; | ||
use Illuminate\Database\Eloquent\Relations\HasMany; | ||
use Illuminate\Database\Eloquent\SoftDeletes; | ||
use Ramsey\Uuid\Uuid; | ||
|
||
class User extends Model | ||
{ | ||
use SoftDeletes; | ||
use UsesHubDB; | ||
|
||
protected $connection = 'iss-sdk'; | ||
|
||
protected $table = 'users'; | ||
|
||
protected $guard_name = 'web'; | ||
|
||
public const TYPE_LIST = [ | ||
'cpf' => 'Pessoa física', | ||
'cnpj' => 'Pessoa jurídica', | ||
]; | ||
|
||
public const KIND_LIST = [ | ||
'self_employed' => 'Autônomo', | ||
'employee' => 'Colaborador', | ||
]; | ||
|
||
public static function boot() | ||
{ | ||
parent::boot(); | ||
|
||
self::creating(function ($model) { | ||
$model->uuid = (string) Uuid::uuid4(); | ||
}); | ||
} | ||
|
||
public function getRouteKeyName() | ||
{ | ||
return 'uuid'; | ||
} | ||
|
||
// | ||
|
||
public function company(): BelongsTo | ||
{ | ||
return $this->belongsTo(Company::class, 'company_id', 'id'); | ||
} | ||
|
||
public function user_companies(): HasMany | ||
{ | ||
return $this->hasMany(UserCompany::class, 'user_id', 'id'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
<?php | ||
|
||
namespace BildVitta\Hub\Models; | ||
|
||
use BildVitta\Hub\Traits\UsesHubDB; | ||
use Illuminate\Database\Eloquent\Model; | ||
use Illuminate\Database\Eloquent\Relations\BelongsTo; | ||
use Illuminate\Database\Eloquent\Relations\HasMany; | ||
use Illuminate\Database\Eloquent\Relations\HasManyThrough; | ||
use Illuminate\Database\Eloquent\Relations\HasOne; | ||
use Illuminate\Database\Eloquent\Relations\MorphMany; | ||
use Illuminate\Database\Eloquent\SoftDeletes; | ||
use Ramsey\Uuid\Uuid; | ||
|
||
class UserCompany extends Model | ||
{ | ||
use SoftDeletes; | ||
use UsesHubDB; | ||
|
||
protected $connection = 'iss-sdk'; | ||
|
||
protected $table = 'user_companies'; | ||
|
||
protected $guard_name = 'web'; | ||
|
||
public static function boot() | ||
{ | ||
parent::boot(); | ||
|
||
self::creating(function ($model) { | ||
$model->uuid = (string) Uuid::uuid4(); | ||
}); | ||
} | ||
|
||
public function getRouteKeyName() | ||
{ | ||
return 'uuid'; | ||
} | ||
|
||
// | ||
|
||
public function user(): BelongsTo | ||
{ | ||
return $this->belongsTo(User::class, 'user_id', 'id'); | ||
} | ||
|
||
public function users(): HasMany | ||
{ | ||
return $this->hasMany(User::class, 'user_id', 'id'); | ||
} | ||
|
||
public function company(): BelongsTo | ||
{ | ||
return $this->belongsTo(Company::class, 'company_id', 'id'); | ||
} | ||
|
||
public function position(): BelongsTo | ||
{ | ||
return $this->belongsTo(Position::class, 'position_id', 'id'); | ||
} | ||
|
||
public function user_company_parent(): HasOne | ||
{ | ||
return $this->hasOne(UserCompanyParentPosition::class, 'user_company_parent_id', 'id'); | ||
} | ||
|
||
public function user_company_children(): HasOne | ||
{ | ||
return $this->hasOne(UserCompanyParentPosition::class, 'user_company_id', 'id'); | ||
} | ||
|
||
public function children_positions(): HasManyThrough | ||
{ | ||
return $this->hasManyThrough( | ||
UserCompany::class, | ||
UserCompanyParentPosition::class, | ||
'user_company_parent_id', | ||
'id', | ||
'id', | ||
'user_company_id', | ||
); | ||
} | ||
|
||
public function parent_position(): HasManyThrough | ||
{ | ||
return $this->hasManyThrough( | ||
UserCompany::class, | ||
UserCompanyParentPosition::class, | ||
'user_company_id', | ||
'id', | ||
'id', | ||
'user_company_parent_id', | ||
); | ||
} | ||
|
||
public function real_estate_developments(): MorphMany | ||
{ | ||
return $this->morphMany(UserCompanyRealEstateDevelopment::class, 'linkable'); | ||
} | ||
} |
Oops, something went wrong.