Esempio n. 1
0
 /**
  * Scope a query to only include guilds from a specific world.
  *
  * @param  \Illuminate\Database\Eloquent\Builder  $query
  * @param  \Apolune\Contracts\Server\World  $world
  * @return \Illuminate\Database\Eloquent\Builder
  */
 public function scopeFromWorld(Builder $query, World $world = null)
 {
     if ($world and $this->hasColumn('world_id') and worlds()->count() > 1) {
         return $query->where('world_id', $world->id());
     }
     return $query;
 }
Esempio n. 2
0
 /**
  * Display the create guild form.
  *
  * @param  string  $world  null
  * @return \Illuminate\View\View
  */
 public function create($world = null)
 {
     if ($worlds = worlds() and $worlds->count() > 1 and !$world) {
         return redirect('/guilds');
     }
     return view('theme::guilds.overview.create', compact('world', 'worlds'));
 }
Esempio n. 3
0
 /**
  * Scope a query to only include players from a specific world.
  *
  * @param  \Illuminate\Database\Eloquent\Builder  $query
  * @param  \Apolune\Contracts\Server\World  $world
  * @return \Illuminate\Database\Eloquent\Builder
  */
 public function scopeFromWorld($query, $world)
 {
     if ($this->hasColumn('world_id') and worlds()->count() > 1) {
         return $query->where('world_id', $world->id());
     }
     return $query;
 }
Esempio n. 4
0
 /**
  * Display a list of all available worlds.
  *
  * @return \Illuminate\View\View
  */
 public function form()
 {
     $worlds = worlds();
     if ($worlds->count() <= 1) {
         return $this->show();
     }
     return view('theme::highscore.form', compact('worlds'));
 }
Esempio n. 5
0
 /**
  * Display a specific world.
  *
  * @param  \Apolune\Contracts\Server\World  $world  null
  * @return \Illuminate\View\View
  */
 public function show($world = null)
 {
     $world = $world ?: worlds()->first();
     list($sort, $order) = $this->getSortable();
     $groups = app('player')->fromWorld($world)->online()->get()->sortBy($sort, SORT_REGULAR, $order === 'DESC')->groupBy(function ($player) {
         return strtoupper(substr($player->name(), 0, 1));
     });
     return view('theme::worlds.show', compact('world', 'sort', 'order', 'groups'));
 }
Esempio n. 6
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next, $redirect = '/')
 {
     $world = $this->router->getCurrentRoute()->getParameter('world');
     if (worlds()->count() > 1 and !$world) {
         if ($request->ajax()) {
             return response('Unauthorized.', 401);
         } else {
             return redirect($redirect);
         }
     }
     return $next($request);
 }
Esempio n. 7
0
 /**
  * Execute the job.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Apolune\Contracts\Account\Player|null
  */
 public function handle(Request $request)
 {
     $player = app('player');
     $player->name = ucwords(strtolower($request->get('player')));
     $player->account_id = $this->account->id();
     $player->vocation = $request->get('vocation', vocations(true)->first()->id());
     $player->town_id = $request->get('town', towns(true)->first()->id());
     $player->world_id = $request->get('world', worlds()->first()->id());
     $player->sex = $request->get('sex', genders()->first()->id());
     $player->conditions = '';
     $player->save();
     event(new Created($player, $this->account));
     return $player;
 }
Esempio n. 8
0
<?php

if (worlds()->count() > 1) {
    return require_once __DIR__ . '/Routes/MultiWorld.php';
}
return require_once __DIR__ . '/Routes/SingleWorld.php';
Esempio n. 9
0
 /**
  * Show the change world form.
  *
  * @param  \Apolune\Contracts\Account\Player  $player
  * @return \Illuminate\View\View
  */
 public function form(Player $player)
 {
     $worlds = worlds()->forget($player->world()->id());
     return view('theme::account.player.world.form', compact('player', 'worlds'));
 }
Esempio n. 10
0
 /**
  * Get a specific world by its slug.
  *
  * @param  string  $slug
  * @return \Apolune\Contracts\Server\World
  */
 function world_by_slug($slug)
 {
     $worlds = worlds();
     return head(array_where($worlds, function ($key, $world) use($slug) {
         return strtolower($world->slug()) === strtolower($slug);
     }));
 }
Esempio n. 11
0
 /**
  * Retrieve the player world.
  *
  * @return \Apolune\Contracts\Server\World
  */
 public function world()
 {
     if ($this->hasColumn('world_id')) {
         return world($this->world_id);
     }
     return worlds()->first();
 }