mirror of
https://github.com/slawkens/myaac.git
synced 2025-04-26 17:29:21 +02:00
Create guild_rank entries, in case MySQL trigger not loaded
This commit is contained in:
parent
4c0739d3e9
commit
d9c1b2507c
@ -10,6 +10,8 @@
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
use MyAAC\Models\GuildRank;
|
||||
|
||||
require __DIR__ . '/base.php';
|
||||
|
||||
$guild_name = isset($_REQUEST['guild']) ? urldecode($_REQUEST['guild']) : NULL;
|
||||
@ -124,14 +126,29 @@ if(isset($todo) && $todo == 'save')
|
||||
$player->setRank($rank);
|
||||
}
|
||||
}
|
||||
|
||||
if ($db->hasTable('guild_ranks')) {
|
||||
if (!GuildRank::where('guild_id', $new_guild->getId())->first()) {
|
||||
$ranks = [
|
||||
['level' => 3, 'name' => 'the Leader'],
|
||||
['level' => 2, 'name' => 'a Vice-Leader'],
|
||||
['level' => 1, 'name' => 'a Member'],
|
||||
];
|
||||
|
||||
foreach ($ranks as $rank) {
|
||||
GuildRank::create([
|
||||
'guild_id' => $new_guild->getId(),
|
||||
'name' => $rank['name'],
|
||||
'level' => $rank['level'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$twig->display('guilds.create.success.html.twig', array(
|
||||
'guild_name' => $guild_name,
|
||||
'leader_name' => $player->getName()
|
||||
));
|
||||
|
||||
/*$db->exec('INSERT INTO `guild_ranks` (`id`, `guild_id`, `name`, `level`) VALUES (null, '.$new_guild->getId().', "the Leader", 3)');
|
||||
$db->exec('INSERT INTO `guild_ranks` (`id`, `guild_id`, `name`, `level`) VALUES (null, '.$new_guild->getId().', "a Vice-Leader", 2)');
|
||||
$db->exec('INSERT INTO `guild_ranks` (`id`, `guild_id`, `name`, `level`) VALUES (null, '.$new_guild->getId().', "a Member", 1)');*/
|
||||
}
|
||||
else {
|
||||
sort($array_of_player_nig);
|
||||
|
@ -9,6 +9,8 @@ class GuildRank extends Model {
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
protected $fillable = ['guild_id', 'name', 'level'];
|
||||
|
||||
public function guild()
|
||||
{
|
||||
return $this->belongsTo(Guild::class);
|
||||
|
Loading…
x
Reference in New Issue
Block a user