public function postEdit()
 {
     $rules = array('gangid' => 'required|numeric|exists:gangs,id', 'owner' => 'numeric', 'newmember' => 'numeric', 'maxmembers' => 'numeric', 'bank' => 'numeric', 'reason' => 'required');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->passes() && Auth::user()->level >= 2) {
         $members = array();
         foreach (Input::all() as $key => $value) {
             if ($key != 'bank' && $key != '_token' && $key != 'gangid' && $key != 'active' && $key != 'maxmembers' && $key != 'owner' && $key != 'newmember' && $key != 'reason') {
                 $key = str_replace('member_', '', $key);
                 array_push($members, $key);
             }
         }
         if (Input::get('newmember')) {
             array_push($members, Input::get('newmember'));
         }
         $members = Auth::user()->encodeDBArray($members, true);
         $active = 0;
         if (Input::get('active') == 1) {
             $active = 1;
         }
         $gang = Gang::find(Input::get('gangid'));
         if (Auth::user()->level >= 3) {
             $log = new Adminlog();
             $log->type = 'gang';
             $log->editor = Auth::user()->id;
             $log->objectid = Input::get('gangid');
             $log->reason = Input::get('reason');
             $log->difference = $log->getDifference(array('owner' => $gang->owner, 'members' => $gang->members, 'maxmembers' => $gang->maxmembers, 'bank' => $gang->bank, 'active' => $gang->active), array('owner' => Input::get('owner'), 'members' => $members, 'maxmembers' => Input::get('maxmembers') * 1, 'bank' => Input::get('bank') * 1, 'active' => $active));
             $log->save();
             $gang->members = $members;
             $gang->maxmembers = Input::get('maxmembers');
             $gang->owner = Input::get('owner');
             $gang->bank = Input::get('bank');
             $gang->active = $active;
         } else {
             $log = new Adminlog();
             $log->type = 'gang';
             $log->editor = Auth::user()->id;
             $log->objectid = Input::get('gangid');
             $log->reason = Input::get('reason');
             $log->difference = $log->getDifference(array('members' => $gang->members, 'maxmembers' => $gang->maxmembers), array('members' => $members, 'maxmembers' => Input::get('maxmembers') * 1));
             $log->save();
             $gang->members = $members;
             $gang->maxmembers = Input::get('maxmembers');
         }
         $gang->save();
         return Redirect::to('/gangs')->with(array('message' => 'Die Änderung wurde erfolgreich übernommen.', 'type' => 'success'));
     } else {
         return Redirect::to('/gangs')->with(array('message' => 'Leider ist ein Fehler aufgetreten, die Änderung wurde verworfen.', 'type' => 'danger'));
     }
 }
Example #2
0
    foreach ($logs as $key => $log) {
        $logs[$key]->editor_name = User::find($log->editor)->username;
        $logs[$key]->difference = unserialize($log->difference);
        $logs[$key]->differences = array();
        foreach ($logs[$key]->difference as $differencekey => $difference) {
            $logs[$key]->differences[] = array($differencekey, $difference[0], $difference[1]);
        }
        $log->search_letter = strtolower(substr($log->type, 0, 1));
        switch ($log->type) {
            case 'player':
                $logs[$key]->type = 'Spieler';
                $logs[$key]->object_name = Player::find($log->objectid)['name'];
                break;
            case 'gang':
                $logs[$key]->type = 'Gang';
                $logs[$key]->object_name = Gang::find($log->objectid)['name'];
                break;
            case 'vehicle':
                $logs[$key]->type = 'Fahrzeug';
                $logs[$key]->object_name = Vehicle::find($log->objectid)['classname'];
                break;
        }
    }
    return View::make('main', array('level_label' => $level_label, 'counter' => $counter))->nest('content', 'logs', array('level_label' => $level_label, 'logs' => $logs, 'search' => $search, 'type' => $type));
}));
Route::get('/statistics', array('before' => 'auth', function () use($level_label, $counter) {
    $statistics = DB::table('statistics')->orderBy('timestamp', 'asc')->get();
    return View::make('main', array('level_label' => $level_label, 'counter' => $counter))->nest('content', 'statistics', array('level_label' => $level_label, 'statistics' => $statistics));
}));
Route::get('/donators', array('before' => 'auth|admin', function () use($level_label, $counter) {
    $donators = DB::table('players')->where('donatorlvl', '>', 0)->paginate(50);