/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $data = []; $data['badges'] = Badge::all()->count(); $data['questions'] = Question::published()->count(); $data['answers'] = User::Member()->with('answeredQuestions')->count(); $data['members'] = User::Member()->count(); return view('admin.dashboard.index', compact('data')); }
public function giveBadge(RewardBadgeRequest $request) { $user = User::findOrFail($request->input('username')); $badge = Badge::findOrFail($request->input('badge')); if (Game::incrementBadge($user, $badge)) { return redirect()->route('admin.rewards.index')->with('success', trans('admin/reward/messages.badge_given.success', ['username' => $user->username, 'badge' => $badge->name])); } else { return redirect()->route('admin.rewards.index')->with('error', trans('admin/reward/messages.badge_given.error', ['username' => $user->username])); } }
/** * Run the database seeds. * * @return void */ public function run() { DB::table('user_profiles')->delete(); $profile = [['username' => 'admin', 'bio' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi. Nulla quis sem at nibh elementum imperdiet. Duis sagittis ipsum. Praesent mauris. Fusce nec tellus sed augue semper porta. Mauris massa. Vestibulum lacinia arcu eget nulla. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Curabitur sodales ligula in libero.', 'url' => 'http://www.example.org/admin', 'phone' => '+34935555555', 'mobile' => '+34934444444', 'date_of_birth' => \Carbon\Carbon::createFromDate(1977, 1, 28)->toDateTimeString(), 'gender' => 'male', 'twitter' => 'https://twitter.com/pakusland', 'facebook' => 'https://www.facebook.com/paco.orozco', 'linkedin' => 'https://www.linkedin.com/in/pacoorozco', 'github' => 'https://github.com/pacoorozco'], ['username' => 'user', 'bio' => 'Sed dignissim lacinia nunc. Curabitur tortor. Pellentesque nibh. Aenean quam. In scelerisque sem at dolor. Maecenas mattis. Sed convallis tristique sem. Proin ut ligula vel nunc egestas porttitor. Morbi lectus risus, iaculis vel, suscipit quis, luctus non, massa. Fusce ac turpis quis ligula lacinia aliquet. Mauris ipsum. Nulla metus metus, ullamcorper vel, tincidunt sed, euismod in, nibh. Quisque volutpat condimentum velit.', 'url' => 'http://www.example.org/user', 'phone' => '+34935555551', 'mobile' => '+34934444441', 'date_of_birth' => \Carbon\Carbon::createFromDate(2008, 8, 7)->toDateTimeString(), 'gender' => 'male', 'twitter' => 'https://twitter.com/emilisho', 'facebook' => 'https://www.facebook.com/eampudia', 'linkedin' => 'https://www.linkedin.com/in/emilioa', 'github' => '']]; foreach ($profile as $data) { $user = \Gamify\User::where('username', $data['username'])->firstOrFail(); $profile = new \Gamify\UserProfile(array_except($data, ['username'])); $user->profile()->save($profile); } }
/** * Run the database seeds. * * @return void */ public function run() { DB::table('users')->delete(); $users = [['username' => 'admin', 'name' => 'Administrator', 'email' => '*****@*****.**', 'password' => 'admin', 'role' => 'administrator'], ['username' => 'user', 'name' => 'User', 'email' => '*****@*****.**', 'password' => 'user', 'role' => 'default']]; foreach ($users as $data) { $user = \Gamify\User::create(['username' => $data['username'], 'name' => $data['name'], 'email' => $data['email'], 'password' => $data['password'], 'role' => $data['role']]); $profile = new \Gamify\UserProfile(['gender' => 'female']); $user->profile()->save($profile); Log::info('Created user ' . $data['username']); } }
/** * Show a list of all the users formatted for Datatables. * * @param Request $request * @param Datatables $dataTable * * @return JsonResponse */ public function data(Request $request, Datatables $dataTable) { // Disable this query if isn't AJAX if (!$request->ajax()) { abort(400); } $users = User::select(['id', 'name', 'username', 'email', 'role'])->orderBy('username', 'ASC'); return $dataTable->of($users)->addColumn('actions', function (User $user) { return view('admin/partials.actions_dd', ['model' => 'users', 'id' => $user->id])->render(); })->removeColumn('id')->make(true); }
/** * Handle the event. * * @param User $user * * @return void */ public function handle(User $user, $remember) { $user->last_login = Carbon::now(); $user->save(); }
/** * Get a collection with members ordered by Experience Points. * * @param int $limitTopUsers * * @return mixed */ public static function getRanking($limitTopUsers = 10) { $users = User::Member()->with('points')->get(); $users = $users->sortByDesc(function ($user) { return $user->getExperiencePoints(); })->take($limitTopUsers); return $users; }
/* |-------------------------------------------------------------------------- | Application Routes |-------------------------------------------------------------------------- | | Here is where you can register all of the routes for an application. | It's a breeze. Simply tell Laravel the URIs it should respond to | and give it the controller to call when that URI is requested. | */ /** ------------------------------------------ * Route model binding * ------------------------------------------. */ Route::bind('username', function ($value) { return \Gamify\User::where('username', $value)->first(); }); Route::bind('question', function ($value) { return \Gamify\Question::where('shortname', $value)->first(); }); Route::model('users', '\\Gamify\\User'); Route::model('badges', '\\Gamify\\Badge'); Route::model('levels', '\\Gamify\\Level'); Route::model('questions', '\\Gamify\\Question'); Route::model('actions', '\\Gamify\\QuestionAction'); // Authentication routes... Route::get('auth/login', 'Auth\\AuthController@getLogin'); Route::post('auth/login', 'Auth\\AuthController@postLogin'); Route::get('auth/logout', 'Auth\\AuthController@getLogout'); // Registration routes... //Route::get('auth/register', 'Auth\AuthController@getRegister');