public function run() { $faker = $this->beginSeeding(new App\UserSetting()); $users = App\User::get(); foreach ($users as $user) { $user->setting()->create(['noti_email' => $faker->randomElement([0, 1]), 'noti_slack' => $faker->randomElement([0, 1]), 'noti_hipchat' => $faker->randomElement([0, 1])]); } $this->endSeeding(); }
/** * Run the database seeds. * * @return void */ public function run() { $positions = ['Banja Luka' => ['lat' => '44.7785709', 'lng' => '17.1361267'], 'Gradiska' => ['lat' => '45.1413827', 'lng' => '17.2405045'], 'Srbac' => ['lat' => '45.0965046', 'lng' => '17.5078242'], 'Mrkonjic Grad' => ['lat' => '44.4149267', 'lng' => '17.0813563'], 'Laktasi' => ['lat' => '44.9075524', 'lng' => '17.2817192'], 'Bijeljina' => ['lat' => '44.760706', 'lng' => '19.1697901'], 'Mostar' => ['lat' => '43.3395487', 'lng' => '17.786221'], 'Sarajevo' => ['lat' => '43.3395487', 'lng' => '17.786221'], 'Pale' => ['lat' => '43.8174955', 'lng' => '18.5493794'], 'Prijedor' => ['lat' => '44.9828959', 'lng' => '16.6664094'], 'Prnjavor' => ['lat' => '44.8688679', 'lng' => '17.6325089'], 'Novi Sad' => ['lat' => '45.2722076', 'lng' => '19.7794008']]; $users = App\User::get(); foreach ($users as $user) { $stations = factory(App\Station::class, 2)->make(); foreach ($stations as $station) { $position = array_shift($positions); $station->lat = $position['lat']; $station->lng = $position['lng']; } $user->stations()->saveMany($stations); } $tags = App\Tag::get(); $stations = App\Station::get(); foreach ($stations as $station) { $aerometrics = factory(App\Aerometric::class, 20)->make(); $station->tags()->sync($tags->random(3)->lists('id')->toArray()); $station->aerometrics()->saveMany($aerometrics); } }
return View::make('admin.index', array( 'users'=> $users, 'document_list' => $document_list, 'systems' => $systems, 'users' => $users )); }]);*/ Route::get('/admin', ['middleware' => 'auth', function () { if (Auth::getUser()->type() != 'Admin') { return Redirect::to('/')->with('message', 'Please login as an admin to continue'); } $users = App\User::get(); return View::make('admin.users', array('users' => $users)); }]); Route::get('/admin/users/add', function () { $users = App\User::get(); return View::make('admin.add_user', array('users' => $users)); }); Route::get('/admin/users/edit/{id}', function ($id) { $users = App\User::find($id); return View::make('/admin.edit_user', array('users' => $users)); }); Route::post('/admin/users/edit/{id}', function ($id) { $input = Input::all(); $validity = Validator::make($input, array('firstname' => 'Required|Min:3|Max:80', 'lastname' => 'Required|Min:3|Max:80', 'username' => 'Required|Min:3|Max:80', 'user_type' => 'Min:3|Max:80')); if ($validity->fails()) { $messages = $validity->messages(); return Redirect::to('/admin/')->withErrors($validity); } else { \App\User::where('id', $id)->update(array('firstname' => $input['firstname'], 'lastname' => $input['lastname'], 'username' => $input['username'], 'type' => $input['user_type'])); return Redirect::to('/admin/')->with('success', "Update Successful.");
</div> </div> <div class="form-group {{ $errors->has('user_id') ? 'has-error' : '' }}" > <div class="row"> <div class="col-md-6 form-control-default"> {!! Form::label('user_id','User') !!} {!! $errors->first('user_id', '<spam class="help-block">:message</spam>') !!} <?php $user = App\User::get(); ?> {!! Form::select('user_id',[''=>'Select a User', 'Users'=>$user->lists('first_name','email')],null,['class' => 'form-control ','id'=>'user']) !!} </div> <div class="col-md-6" style="padding-top: 24px;"> <a href="#" class="btn btn-primary " title="delete" data-toggle="modal" data-target="#myModal"> Not a registered user </a> </div> </div> </div> <div class="row">
/** * Display a listing of the resource. * * @return Response */ public function index() { $users = new \App\User(); $data = array('users' => $users->get()); return view('users')->with($data); }
// }); /** * eine Route-Gruppe * * alle urls, die mit "admin" beginnen und dann die entsprechende Url, also z.B. /admin/manage */ $app['router']->group('admin', function () use($app) { $app['router']->get('/', 'AdminController@dashboard'); $app['router']->get('manage', 'AdminController@manage'); }); /** * eine Route mit einer Variable und einer Regex-Spezifikation, welche die Variable erfüllen muss */ $app['router']->get('{$id:int}', function ($id) { echo 'id: ' . $id; }); $app['router']->get('user/{$id:int}', 'HomeController@show'); $app['router']->get('test', function () { return \View::render('test'); }); $app['router']->get('/', function () { $users = new App\User(); view('home', ['var1' => 'Beispielvariable', 'var2' => 'oder etwas anderes', 'users' => $users->get()]); }); // $app['router']->get('phpinfo', function() { // echo phpinfo(); // }); $app['router']->get('asdf', 'HomeController@asdf'); $app['router']->post('register', 'HomeController@register'); $app['router']->get('/irgendwas', ['as' => 'irgendwasRoute', 'use' => 'HomeController@index']); $app->run();