CharItem.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. ];
  22. public $timestamps = false;
  23. public static function UPDATEINVENTORYORDER($CharID = - 1)
  24. {
  25. $Characters = null;
  26. $totalAccounts = 0;
  27. if($CharID == -1){
  28. $Characters = CharBase::get();
  29. }
  30. else{
  31. $Characters = CharBase::where('DBKey', $CharID)->get();
  32. }
  33. foreach ($Characters as $Character) {
  34. $slot = 0;
  35. $Items = self::where('Owner', $Character->DBKey)->get();
  36. foreach ($Items as $item) {
  37. $item->Slot = $slot;
  38. $item->update();
  39. $slot++;
  40. }
  41. $totalAccounts++;
  42. }
  43. return $totalAccounts;
  44. }
  45. //mn = market, in = inventario
  46. public static function CHECKINVENTORYORDER($CharID = - 1, $StrRecordKind = 'in')
  47. {
  48. $ID = 0;
  49. $Data[] = [];
  50. $totalAccounts = 0;
  51. $Characters = null;
  52. if($CharID == -1){
  53. $Characters = CharBase::get();
  54. }
  55. else{
  56. $Characters = CharBase::where('DBKey', $CharID)->get();
  57. }
  58. foreach ($Characters as $key => $Character) {
  59. $check = true;
  60. $slot = 0;
  61. $Items = self::where('Owner', $Character->DBKey)->where('StrRecordKind', $StrRecordKind)->get();
  62. foreach ($Items as $item) {
  63. if($item->Slot != $slot){
  64. $item->Slot = $slot;
  65. $item->update();
  66. $Data[$ID] = [
  67. 'account' => $item->Owner,
  68. 'Name' => $Character->Name
  69. ];
  70. $ID++;
  71. }
  72. $slot++;
  73. }
  74. }
  75. return $Data;
  76. }
  77. }