From 4db6dac43953b5a0e7c6fd83cdac60da93386984 Mon Sep 17 00:00:00 2001 From: drkthunder02 Date: Wed, 10 Mar 2021 23:29:30 +0900 Subject: [PATCH] added primary keys to all models --- app/Models/Admin/AllowedLogin.php | 3 ++ .../AfterActionReports/AfterActionReport.php | 41 +++++++++++++++++++ .../AfterActionReportComment.php | 33 +++++++++++++++ app/Models/Blacklist/BlacklistEntity.php | 3 ++ app/Models/Contracts/SupplyChainBid.php | 7 +++- app/Models/Contracts/SupplyChainContract.php | 3 ++ app/Models/Esi/EsiScope.php | 5 ++- app/Models/Esi/EsiToken.php | 6 ++- app/Models/Finances/AllianceWalletJournal.php | 3 ++ app/Models/Jobs/JobStatus.php | 3 ++ app/Models/Lookups/AllianceLookup.php | 3 ++ app/Models/Lookups/CharacterLookup.php | 3 ++ app/Models/Lookups/CorporationLookup.php | 3 ++ app/Models/Lookups/ItemLookup.php | 3 ++ app/Models/Lookups/SolarSystem.php | 3 ++ app/Models/Mail/SentMail.php | 3 ++ app/Models/MiningTax/Invoice.php | 7 +++- app/Models/MiningTax/Ledger.php | 5 ++- app/Models/MiningTax/Observer.php | 11 ++--- app/Models/MiningTax/Payment.php | 5 ++- app/Models/Moon/Config.php | 3 ++ app/Models/Moon/ItemComposition.php | 3 ++ app/Models/SRP/SrpFleetType.php | 10 +++++ app/Models/SRP/SrpPayout.php | 2 +- app/Models/SRP/SrpShipType.php | 6 ++- app/Models/ScheduledTask/ScheduleJob.php | 3 ++ app/Models/Structure/Asset.php | 4 ++ app/Models/Structure/Service.php | 2 +- app/Models/Structure/Structure.php | 6 ++- app/Models/User/AvailableUserPermission.php | 3 ++ app/Models/User/AvailableUserRole.php | 3 ++ app/Models/User/User.php | 3 ++ app/Models/User/UserAlt.php | 4 ++ app/Models/User/UserPermission.php | 3 ++ app/Models/User/UserRole.php | 8 ++++ 35 files changed, 197 insertions(+), 19 deletions(-) create mode 100644 app/Models/AfterActionReports/AfterActionReport.php create mode 100644 app/Models/AfterActionReports/AfterActionReportComment.php diff --git a/app/Models/Admin/AllowedLogin.php b/app/Models/Admin/AllowedLogin.php index b92fa6c54..5f433580a 100644 --- a/app/Models/Admin/AllowedLogin.php +++ b/app/Models/Admin/AllowedLogin.php @@ -9,6 +9,9 @@ class AllowedLogin extends Model //Table Name public $table = 'allowed_logins'; + //Primary Key + public $primaryKey = 'id'; + //Timestamps public $timestamps = true; diff --git a/app/Models/AfterActionReports/AfterActionReport.php b/app/Models/AfterActionReports/AfterActionReport.php new file mode 100644 index 000000000..fdd82cf9d --- /dev/null +++ b/app/Models/AfterActionReports/AfterActionReport.php @@ -0,0 +1,41 @@ +hasMany(App\Models\AfterActionReports\AfterActionReportComment::class, 'report_id', 'id'); + + } +} diff --git a/app/Models/AfterActionReports/AfterActionReportComment.php b/app/Models/AfterActionReports/AfterActionReportComment.php new file mode 100644 index 000000000..03dde5517 --- /dev/null +++ b/app/Models/AfterActionReports/AfterActionReportComment.php @@ -0,0 +1,33 @@ +belongsTo(App\Models\AfterActionReports\AfterActionReport::class, 'id', 'report_id'); + } +} diff --git a/app/Models/Blacklist/BlacklistEntity.php b/app/Models/Blacklist/BlacklistEntity.php index 1e06822cd..0338a8f86 100644 --- a/app/Models/Blacklist/BlacklistEntity.php +++ b/app/Models/Blacklist/BlacklistEntity.php @@ -9,6 +9,9 @@ class BlacklistEntity extends Model //Table Name public $table = 'alliance_blacklist'; + //Primary Key + public $primaryKey = 'id'; + //Timestamps public $timestamps = true; diff --git a/app/Models/Contracts/SupplyChainBid.php b/app/Models/Contracts/SupplyChainBid.php index a9394ca61..3cc51ff4f 100644 --- a/app/Models/Contracts/SupplyChainBid.php +++ b/app/Models/Contracts/SupplyChainBid.php @@ -9,6 +9,9 @@ class SupplyChainBid extends Model //Table Name public $table = 'supply_chain_bids'; + //Primary Key + public $primaryKey = 'id'; + // Timestamps public $timestamps = true; @@ -29,11 +32,11 @@ class SupplyChainBid extends Model //Relationships public function ContractId() { - return $this->hasOne('App\Models\Contracts\SupplyChainContract', 'contract_id', 'contract_id'); + return $this->belongsTo(App\Models\Contracts\SupplyChainContract::class, 'contract_id', 'contract_id'); } public function Contract() { - return $this->belongsTo(SupplyChainContract::class); + return $this->belongsTo(App\Models\Contracts\SupplyChainContract::class); } //Model functions diff --git a/app/Models/Contracts/SupplyChainContract.php b/app/Models/Contracts/SupplyChainContract.php index a4ee68c91..01e44edd9 100644 --- a/app/Models/Contracts/SupplyChainContract.php +++ b/app/Models/Contracts/SupplyChainContract.php @@ -9,6 +9,9 @@ class SupplyChainContract extends Model //Table Name public $table = 'supply_chain_contracts'; + //Primary Key + public $primaryKey = 'id'; + //Timestamps public $timestamps = true; diff --git a/app/Models/Esi/EsiScope.php b/app/Models/Esi/EsiScope.php index ba24eeff2..eda050da0 100644 --- a/app/Models/Esi/EsiScope.php +++ b/app/Models/Esi/EsiScope.php @@ -9,6 +9,9 @@ class EsiScope extends Model // Table Name protected $table = 'EsiScopes'; + //Primary Key + public $primaryKey = 'id'; + // Timestamps public $timestamps = true; @@ -23,6 +26,6 @@ class EsiScope extends Model ]; public function user() { - return $this->belongsTo('App\Models\User\User', 'character_id', 'character_id'); + return $this->belongsTo(App\Models\User\User::class, 'character_id', 'character_id'); } } diff --git a/app/Models/Esi/EsiToken.php b/app/Models/Esi/EsiToken.php index d5f5f6f5d..fda925bd0 100644 --- a/app/Models/Esi/EsiToken.php +++ b/app/Models/Esi/EsiToken.php @@ -28,7 +28,11 @@ class EsiToken extends Model 'expires_in', ]; + public function user() { + return $this->belongsTo(App\Models\User\User::class, 'character_id', 'character_id'); + } + public function esiscopes() { - return $this->hasMany('App\Models\EsiScope', 'character_id', 'character_id'); + return $this->hasMany(App\Models\EsiScope::class, 'character_id', 'character_id'); } } diff --git a/app/Models/Finances/AllianceWalletJournal.php b/app/Models/Finances/AllianceWalletJournal.php index 64e047b79..978a3c193 100644 --- a/app/Models/Finances/AllianceWalletJournal.php +++ b/app/Models/Finances/AllianceWalletJournal.php @@ -11,6 +11,9 @@ class AllianceWalletJournal extends Model */ protected $table = 'alliance_wallet_journal'; + //Primary Key + public $primaryKey = 'id'; + /** * Timestamps */ diff --git a/app/Models/Jobs/JobStatus.php b/app/Models/Jobs/JobStatus.php index 48a2bbf46..c2d828858 100644 --- a/app/Models/Jobs/JobStatus.php +++ b/app/Models/Jobs/JobStatus.php @@ -9,6 +9,9 @@ class JobStatus extends Model //Table Name public $table = 'job_statuses'; + //Primary Key + public $primaryKey = 'id'; + //Timestamps public $timestaps = true; diff --git a/app/Models/Lookups/AllianceLookup.php b/app/Models/Lookups/AllianceLookup.php index e1df3ab64..ed211cd5b 100644 --- a/app/Models/Lookups/AllianceLookup.php +++ b/app/Models/Lookups/AllianceLookup.php @@ -9,6 +9,9 @@ class AllianceLookup extends Model //Table Name public $table = 'alliance_lookup'; + //Primary Key + public $primaryKey = 'id'; + //Timestamps public $timestamps = false; diff --git a/app/Models/Lookups/CharacterLookup.php b/app/Models/Lookups/CharacterLookup.php index 8ddc8f9d2..ebda70ed3 100644 --- a/app/Models/Lookups/CharacterLookup.php +++ b/app/Models/Lookups/CharacterLookup.php @@ -9,6 +9,9 @@ class CharacterLookup extends Model //Table Name public $table = 'character_lookup'; + //Primary Key + public $primaryKey = 'id'; + //Timestamps public $timestamps = false; diff --git a/app/Models/Lookups/CorporationLookup.php b/app/Models/Lookups/CorporationLookup.php index 805ef9050..a38c9dd2f 100644 --- a/app/Models/Lookups/CorporationLookup.php +++ b/app/Models/Lookups/CorporationLookup.php @@ -9,6 +9,9 @@ class CorporationLookup extends Model //Table Name public $table = 'corporation_lookup'; + //Primary Key + public $primaryKey = 'id'; + //Timestamps public $timestamps = false; diff --git a/app/Models/Lookups/ItemLookup.php b/app/Models/Lookups/ItemLookup.php index 89004ee7d..3e61cd28b 100644 --- a/app/Models/Lookups/ItemLookup.php +++ b/app/Models/Lookups/ItemLookup.php @@ -11,6 +11,9 @@ class ItemLookup extends Model */ public $table = 'item_lookup'; + //Primary Key + public $primaryKey = 'id'; + /** * Timestamps */ diff --git a/app/Models/Lookups/SolarSystem.php b/app/Models/Lookups/SolarSystem.php index 901fdde0f..77e29121f 100644 --- a/app/Models/Lookups/SolarSystem.php +++ b/app/Models/Lookups/SolarSystem.php @@ -9,6 +9,9 @@ class SolarSystem extends Model //Table Name public $table = 'solar_systems'; + //Primary Key + public $primaryKey = 'id'; + //Timestamps public $timestamps = false; diff --git a/app/Models/Mail/SentMail.php b/app/Models/Mail/SentMail.php index 9fe769131..fb2f393ca 100644 --- a/app/Models/Mail/SentMail.php +++ b/app/Models/Mail/SentMail.php @@ -9,6 +9,9 @@ class SentMail extends Model //Table Name protected $table = 'sent_mails'; + //Primary Key + public $primaryKey = 'id'; + //Timestamps public $timestamps = false; diff --git a/app/Models/MiningTax/Invoice.php b/app/Models/MiningTax/Invoice.php index 6d679e314..154dae5b3 100644 --- a/app/Models/MiningTax/Invoice.php +++ b/app/Models/MiningTax/Invoice.php @@ -9,6 +9,9 @@ class Invoice extends Model //Table Name protected $table = 'alliance_mining_tax_invoices'; + //Primary Key + public $primaryKey = 'id'; + //Timestamps public $timestamps = true; @@ -28,7 +31,7 @@ class Invoice extends Model ]; public function getPayment() { - return $this->hasMany('App\Models\MiningTax\Payment', 'invoice_id', 'invoice_id'); + return $this->hasOne(App\Models\MiningTax\Payment::class, 'invoice_id', 'invoice_id'); } public function getCharacterId() { @@ -44,7 +47,7 @@ class Invoice extends Model } public function getLedgers() { - return $this->hasMany('App\Models\MiningTax\Ledger', 'invoice_id', 'invoice_id'); + return $this->hasMany(App\Models\MiningTax\Ledger::class, 'invoice_id', 'invoice_id'); } public function getInvoiceAmount() { diff --git a/app/Models/MiningTax/Ledger.php b/app/Models/MiningTax/Ledger.php index a21c848b7..03984e72e 100644 --- a/app/Models/MiningTax/Ledger.php +++ b/app/Models/MiningTax/Ledger.php @@ -9,6 +9,9 @@ class Ledger extends Model //Table Name protected $table = 'alliance_mining_tax_ledgers'; + //Primary Key + public $primaryKey = 'id'; + //Timestamps public $timestamps = false; @@ -31,7 +34,7 @@ class Ledger extends Model ]; public function getInvoice() { - return $this->belongsTo('App\Models\MiningTax\Invoice', 'invoice_id', 'invoice_id'); + return $this->belongsTo(App\Models\MiningTax\Invoice::class, 'invoice_id', 'invoice_id'); } diff --git a/app/Models/MiningTax/Observer.php b/app/Models/MiningTax/Observer.php index 016016e1e..eedb07a6f 100644 --- a/app/Models/MiningTax/Observer.php +++ b/app/Models/MiningTax/Observer.php @@ -9,6 +9,9 @@ class Observer extends Model //Table Name protected $table = 'alliance_mining_tax_observers'; + //Primary Key + public $primaryKey = 'id'; + //Timestamps public $timestamps = true; @@ -21,11 +24,5 @@ class Observer extends Model 'last_updated', 'observer_id', 'observer_type', - ]; - - public function getLedgers() { - return $this->hasMany('App\Models\MiningTax\Ledger', 'observer_id', 'observer_id'); - } - - + ]; } diff --git a/app/Models/MiningTax/Payment.php b/app/Models/MiningTax/Payment.php index ad9741f58..b04d9b3c6 100644 --- a/app/Models/MiningTax/Payment.php +++ b/app/Models/MiningTax/Payment.php @@ -9,6 +9,9 @@ class Payment extends Model //Table Name protected $table = 'alliance_mining_tax_payments'; + //Primary Key + public $primaryKey = 'id'; + //Timestamps public $timestamps = true; @@ -28,6 +31,6 @@ class Payment extends Model ]; public function getInvoice() { - return $this->belongsTo('App\Models\MiningTax\Invoice', 'invoice_id', 'invoice_id'); + return $this->belongsTo(App\Models\MiningTax\Invoice::class, 'invoice_id', 'invoice_id'); } } diff --git a/app/Models/Moon/Config.php b/app/Models/Moon/Config.php index 52a0bd4b8..fa2544fa4 100644 --- a/app/Models/Moon/Config.php +++ b/app/Models/Moon/Config.php @@ -9,6 +9,9 @@ class Config extends Model // Table Name protected $table = 'Config'; + //Primary Key + public $primaryKey = 'id'; + // Timestamps public $timestamps = false; diff --git a/app/Models/Moon/ItemComposition.php b/app/Models/Moon/ItemComposition.php index 974221934..b34786b60 100644 --- a/app/Models/Moon/ItemComposition.php +++ b/app/Models/Moon/ItemComposition.php @@ -9,6 +9,9 @@ class ItemComposition extends Model // Table Name protected $table = 'ItemComposition'; + //Primary Key + public $primaryKey = 'id'; + // Timestamps public $timestamps = false; } diff --git a/app/Models/SRP/SrpFleetType.php b/app/Models/SRP/SrpFleetType.php index 83a217f44..27eac2006 100644 --- a/app/Models/SRP/SrpFleetType.php +++ b/app/Models/SRP/SrpFleetType.php @@ -14,4 +14,14 @@ class SrpFleetType extends Model //Timestamps public $timestamps = false; + + /** + * The attributes that are mass assignable + * + * @var array + */ + protected $fillable = [ + 'code', + 'description', + ]; } diff --git a/app/Models/SRP/SrpPayout.php b/app/Models/SRP/SrpPayout.php index 73b2a0a95..917444191 100644 --- a/app/Models/SRP/SrpPayout.php +++ b/app/Models/SRP/SrpPayout.php @@ -22,6 +22,6 @@ class SrpPayout extends Model ]; public function shipType() { - return $this->belongsTo(SrpShipType::class); + return $this->belongsTo(SrpShipType::class, 'code', 'code'); } } diff --git a/app/Models/SRP/SrpShipType.php b/app/Models/SRP/SrpShipType.php index 273a4cc51..50b3dcda0 100644 --- a/app/Models/SRP/SrpShipType.php +++ b/app/Models/SRP/SrpShipType.php @@ -22,6 +22,10 @@ class SrpShipType extends Model ]; public function costCode() { - return $this->hasOne('App\Models\SRP\SrpPayout', 'code', 'code'); + return $this->hasOne(App\Models\SRP\SrpPayout::class, 'code', 'code'); + } + + public function fleetType() { + return $this->belongsTo(App\Models\SRP\SrpFleetType::class, 'code', 'code'); } } diff --git a/app/Models/ScheduledTask/ScheduleJob.php b/app/Models/ScheduledTask/ScheduleJob.php index 97190c91f..3b8c42889 100644 --- a/app/Models/ScheduledTask/ScheduleJob.php +++ b/app/Models/ScheduledTask/ScheduleJob.php @@ -6,10 +6,13 @@ use Illuminate\Database\Eloquent\Model; class ScheduleJob extends Model { + //Table Name protected $table = 'schedule_jobs'; + //Timestamps public $timestamps = true; + //Primary Key public $primaryKey = 'id'; protected $fillable = [ diff --git a/app/Models/Structure/Asset.php b/app/Models/Structure/Asset.php index 3bb8d06fb..26c320624 100644 --- a/app/Models/Structure/Asset.php +++ b/app/Models/Structure/Asset.php @@ -36,4 +36,8 @@ class Asset extends Model 'type_id', 'updated_at', ]; + + public function structure() { + return $this->belongsTo(App\Models\Structure\Structure::class, 'structure_id', 'location_id'); + } } diff --git a/app/Models/Structure/Service.php b/app/Models/Structure/Service.php index 40eddfbcd..3838dda86 100644 --- a/app/Models/Structure/Service.php +++ b/app/Models/Structure/Service.php @@ -27,6 +27,6 @@ class Service extends Model ]; public function structure() { - return $this->hasOne('App\Models\Structure\Structure', 'structure_id', 'structure_id'); + return $this->belongsTo(App\Models\Structure\Structure::class, 'structure_id', 'structure_id'); } } diff --git a/app/Models/Structure/Structure.php b/app/Models/Structure/Structure.php index aac3ab26c..d766d7386 100644 --- a/app/Models/Structure/Structure.php +++ b/app/Models/Structure/Structure.php @@ -50,6 +50,10 @@ class Structure extends Model ]; public function services() { - return $this->hasMany('App\Models\Structure\Service', 'structure_id', 'structure_id'); + return $this->hasMany(App\Models\Structure\Service::class, 'structure_id', 'structure_id'); + } + + public function assets() { + return $this->hasMany(App\Models\Structure\Asset::class, 'location_id', 'structure_id'); } } diff --git a/app/Models/User/AvailableUserPermission.php b/app/Models/User/AvailableUserPermission.php index eae41d2c7..5f6d28beb 100644 --- a/app/Models/User/AvailableUserPermission.php +++ b/app/Models/User/AvailableUserPermission.php @@ -11,6 +11,9 @@ class AvailableUserPermission extends Model */ protected $table = 'available_user_permissions'; + //Primary Key + public $primaryKey = 'id'; + /** * Timestamps enabled for the rows */ diff --git a/app/Models/User/AvailableUserRole.php b/app/Models/User/AvailableUserRole.php index b15628d5e..4994cb06c 100644 --- a/app/Models/User/AvailableUserRole.php +++ b/app/Models/User/AvailableUserRole.php @@ -9,6 +9,9 @@ class AvailableUserRole extends Model //Table Name protected $table = 'available_user_roles'; + //Primary Key + public $primaryKey = 'id'; + //Timestamps public $timestamps = false; diff --git a/app/Models/User/User.php b/app/Models/User/User.php index 18b6f7b7c..14c19371d 100644 --- a/app/Models/User/User.php +++ b/app/Models/User/User.php @@ -22,6 +22,9 @@ class User extends Authenticatable */ protected $table = 'users'; + //Primary Key + public $primaryKey = 'id'; + /** * The attributes that are mass assignable. * diff --git a/app/Models/User/UserAlt.php b/app/Models/User/UserAlt.php index cbb623dec..a5d136d09 100644 --- a/app/Models/User/UserAlt.php +++ b/app/Models/User/UserAlt.php @@ -9,6 +9,10 @@ class UserAlt extends Model //Table Name public $table = 'user_alts'; + //Primary Key + public $primaryKey = 'id'; + + //Timestamps public $timestamps = false; /** diff --git a/app/Models/User/UserPermission.php b/app/Models/User/UserPermission.php index 3f752d71b..a0e935f63 100644 --- a/app/Models/User/UserPermission.php +++ b/app/Models/User/UserPermission.php @@ -11,6 +11,9 @@ class UserPermission extends Model */ protected $table = 'user_permissions'; + //Primary Key + public $primaryKey = 'id'; + /** * The attributes that are mass assignable * diff --git a/app/Models/User/UserRole.php b/app/Models/User/UserRole.php index 015ceb53b..ea7e45f15 100644 --- a/app/Models/User/UserRole.php +++ b/app/Models/User/UserRole.php @@ -11,6 +11,14 @@ class UserRole extends Model */ protected $table = 'user_roles'; + //Primary Key + public $primaryKey = 'id'; + + /** + * Attributes which are mass assignable + * + * @var array + */ protected $fillable = [ 'character_id', 'role',