CharItem.php 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <?php
  2. namespace App\Models\Char;
  3. use Illuminate\Database\Eloquent\Factories\HasFactory;
  4. use Illuminate\Database\Eloquent\Model;
  5. use DB;
  6. use App\Models\Char\CharBase;
  7. class CharItem extends Model
  8. {
  9. protected $connection = "Char";
  10. protected $table = "Table_CharItem";
  11. protected $primaryKey = "CharItemID";
  12. protected $dates = [];
  13. protected $fillable =
  14. [
  15. "Owner", "Slot", "Deleted", "ItemSerial", "StrRecordKind", "Account", "RecId", "Amount", "ClientSlot", "ClientEquip", "Durability",
  16. "ReinforceLevel", "SellerDbKey", "SellerName", "SellPrice", "RegisterDate", "SoldDate", "bSold", "MailDbKey", "Belong", "RemoveBelongCount",
  17. "Quality", "QUalityEffect", "LinkItemSerial", "Storage", "FellowDbKey", "Opened", "Toggle", "SSProperty", "SSEnabled01", "SSRecId01", "SSEnabled02",
  18. "SSRecId02", "SSEnabled03", "SSRecId03", "StrPlus", "DexPlus", "IntPlus", "VtlPlus", "MtlPlus", "Color", "SubColor", "ProducerName", "ROEffect01",
  19. "ROEffectValue01", "ROEffect02", "ROEffectValue02", "ROEffect03", "ROEffectValue03", "ROEffect04", "ROEffectValue04", "ROEffect05", "ROEffectValue05",
  20. "ROEffect06", "ROEffectValue06", "SealedFellowEffect01", "SealedFellowEValue01", "SealedFellowEffect02",
  21. "SealedFellowEValue02",
  22. "SealedFellowSlotCount",
  23. "SealedFellow01",
  24. "SealedFellow01_Effect01",
  25. "SealedFellow01_EValue01",
  26. "SealedFellow01_Effect02",
  27. "SealedFellow01_EValue02",
  28. "SealedFellow02",
  29. "SealedFellow02_Effect01",
  30. "SealedFellow02_EValue01",
  31. "SealedFellow02_Effect02",
  32. "SealedFellow02_EValue02",
  33. "SealedFellow03",
  34. "SealedFellow03_Effect01",
  35. "SealedFellow03_EValue01",
  36. "SealedFellow03_Effect02",
  37. "SealedFellow03_EValue02",
  38. "ExpirationDate",
  39. "CharItemID",
  40. "ItemGrade",
  41. "bSeize",
  42. "SealedFellowEffect03",
  43. "SealedFellowEValue03",
  44. "SealedFellow01_Effect03",
  45. "SealedFellow01_EValue03",
  46. "SealedFellow02_Effect03",
  47. "SealedFellow02_EValue03",
  48. "SealedFellow03_EValue03",
  49. "SealedFellowEffect04",
  50. "SealedFellowEValue04",
  51. "SealedFellow01_Effect04",
  52. "SealedFellow01_EValue04",
  53. "SealedFellow02_Effect04",
  54. "SealedFellow02_EValue04",
  55. "SealedFellow03_Effect04",
  56. "SealedFellow03_EValue04",
  57. "SealedFellow01_ExpirationDate",
  58. "SealedFellow02_ExpirationDate",
  59. "SealedFellow03_ExpirationDate",
  60. "CarvedPeriodDate",
  61. "OverriseCount",
  62. "ReverseReinforceAttemptCount",
  63. "ReverseReinforceCount",
  64. "SealedFellow04",
  65. "SealedFellow04_Effect01",
  66. "SealedFellow04_EValue01",
  67. "SealedFellow04_Effect02",
  68. "SealedFellow04_EValue02",
  69. "SealedFellow04_Effect03",
  70. "SealedFellow04_EValue03",
  71. "SealedFellow04_Effect04",
  72. "SealedFellow04_EValue04",
  73. "SealedFellow04_ExpirationDate",
  74. "ROEffect07",
  75. "ROEffectValue07",
  76. "SealedFellow01_ReinforceLv",
  77. "SealedFellow02_ReinforceLv",
  78. "SealedFellow03_ReinforceLv",
  79. "SealedFellow04_ReinforceLv",
  80. "KeyValueA",
  81. "WeaponAwakenAttackValue",
  82. "WeaponAwakenSkillRecID",
  83. "WeaponAwakenSkillLevel",
  84. "WeaponAwakenEffectParam",
  85. "WeaponAwakenEffectValue",
  86. "WeaponAwakenRecID1",
  87. "WeaponAwakenCount1",
  88. "WeaponAwakenCount2",
  89. "Exp",
  90. "Level"
  91. ];
  92. public $timestamps = false;
  93. public static function UPDATEINVENTORYORDER($CharID = - 1)
  94. {
  95. $Characters = null;
  96. $totalAccounts = 0;
  97. if($CharID == -1){
  98. $Characters = CharBase::get();
  99. }
  100. else{
  101. $Characters = CharBase::where('DBKey', $CharID)->get();
  102. }
  103. foreach ($Characters as $Character) {
  104. $slot = 0;
  105. $Items = self::where('Owner', $Character->DBKey)->get();
  106. foreach ($Items as $item) {
  107. $item->Slot = $slot;
  108. $item->update();
  109. $slot++;
  110. }
  111. $totalAccounts++;
  112. }
  113. return $totalAccounts;
  114. }
  115. //mn = market, in = inventario
  116. public static function CHECKINVENTORYORDER($CharID = - 1, $StrRecordKind = 'in')
  117. {
  118. $ID = 0;
  119. $Data[] = [];
  120. $totalAccounts = 0;
  121. $Characters = null;
  122. if($CharID == -1){
  123. $Characters = CharBase::get();
  124. }
  125. else{
  126. $Characters = CharBase::where('DBKey', $CharID)->get();
  127. }
  128. foreach ($Characters as $key => $Character) {
  129. $check = true;
  130. $slot = 0;
  131. $Items = self::where('Owner', $Character->DBKey)->where('StrRecordKind', $StrRecordKind)->get();
  132. foreach ($Items as $item) {
  133. if($item->Slot != $slot){
  134. $item->Slot = $slot;
  135. $item->update();
  136. $Data[$ID] = [
  137. 'account' => $item->Owner,
  138. 'Name' => $Character->Name
  139. ];
  140. $ID++;
  141. }
  142. $slot++;
  143. }
  144. }
  145. return $Data;
  146. }
  147. }