|
1 | 1 | <?php
|
2 | 2 |
|
| 3 | +use MyAAC\Models\News; |
3 | 4 | use MyAAC\Settings;
|
4 | 5 |
|
5 | 6 | defined('MYAAC') or die('Direct access not allowed!');
|
|
104 | 105 | $player->save();
|
105 | 106 | }
|
106 | 107 |
|
107 |
| - $player_id = 0; |
108 |
| - $query = $db->query("SELECT `id` FROM `players` WHERE `name` = " . $db->quote($player_name) . ";"); |
109 |
| - if($query->rowCount() == 1) { |
110 |
| - $query = $query->fetch(); |
111 |
| - $player_id = $query['id']; |
112 |
| - } |
113 |
| - |
114 |
| - $query = $db->query("SELECT `id` FROM `" . TABLE_PREFIX ."news` WHERE `title` LIKE 'Hello!';"); |
115 |
| - if($query->rowCount() == 0) { |
116 |
| - if(query("INSERT INTO `" . TABLE_PREFIX ."news` (`id`, `type`, `date`, `category`, `title`, `body`, `player_id`, `comments`, `hide`) VALUES (NULL, '1', UNIX_TIMESTAMP(), '2', 'Hello!', 'MyAAC is just READY to use!', " . $player_id . ", 'https://my-aac.org', '0'); |
117 |
| - INSERT INTO `myaac_news` (`id`, `type`, `date`, `category`, `title`, `body`, `player_id`, `comments`, `hide`) VALUES (NULL, '2', UNIX_TIMESTAMP(), '4', 'Hello tickets!', 'https://my-aac.org', " . $player_id . ", '', '0');")) { |
118 |
| - success($locale['step_database_created_news']); |
| 108 | + if(!News::all()->count()) { |
| 109 | + $player_id = 0; |
| 110 | + $tmpNewsPlayer = \MyAAC\Models\Player::where('name', $player_name)->first(); |
| 111 | + if($tmpNewsPlayer) { |
| 112 | + $player_id = $tmpNewsPlayer->id; |
119 | 113 | }
|
| 114 | + |
| 115 | + News::create([ |
| 116 | + 'type' => 1, |
| 117 | + 'date' => time(), |
| 118 | + 'category' => 2, |
| 119 | + 'title' => 'Hello!', |
| 120 | + 'body' => 'MyAAC is just READY to use!', |
| 121 | + 'player_id' => $player_id, |
| 122 | + 'comments' => 'https://my-aac.org', |
| 123 | + 'hide' => 0, |
| 124 | + ]); |
| 125 | + |
| 126 | + News::create([ |
| 127 | + 'type' => 2, |
| 128 | + 'date' => time(), |
| 129 | + 'category' => 4, |
| 130 | + 'title' => 'Hello tickers!', |
| 131 | + 'body' => 'https://my-aac.org', |
| 132 | + 'player_id' => $player_id, |
| 133 | + 'comments' => '', |
| 134 | + 'hide' => 0, |
| 135 | + ]); |
| 136 | + |
| 137 | + success($locale['step_database_created_news']); |
120 | 138 | }
|
121 | 139 |
|
122 | 140 | $settings = Settings::getInstance();
|
|
0 commit comments