public function testDeleteClientOk() { $user = App\User::all()->last(); $client = App\Client::count(); $this->actingAs($user)->call('delete', '/client/' . App\Client::all()->last()->Id); $this->assertNotEquals($client - 1, App\Client::count()); }
public function testAddRepairDateFail3() { $user = App\User::all()->last(); $count = App\Repair::count(); $this->actingAs($user)->visit('/repairs/create')->select(App\Car::all()->last()->LicencePlate, 'LicencePlate')->select(App\Staff::all()->last()->Id, 'StaffId')->check('Ongoing')->type('Oil change', 'Type')->type('Just a routine exercise.', 'Comments')->type('2016-02-14asd', 'StartDate')->type('2016/02/16', 'EndDate')->type('50', 'Cost')->press('Add repair'); $this->assertEquals($count, App\Repair::count()); }
public function testDeleteStaffOk() { $user = App\User::all()->last(); $staff = App\Staff::count(); $this->actingAs($user)->call('delete', '/staff/' . App\Staff::all()->last()->Id); $this->assertNotEquals($staff - 1, App\Staff::count()); }
/** * Run the database seeds. * * @return void */ public function run() { $users = App\User::all(); factory(App\Course::class, 10)->create()->each(function ($course) use($users) { $course->users()->sync($users->random(mt_rand(2, $users->count()))); $course->teachers()->sync($users->random(3)); }); }
/** * Run the database seeds. * * @return void */ public function run() { App\Comment::truncate(); $users = App\User::all(); factory(App\Comment::class, 20)->create()->each(function ($comment) use($users) { $comment->author()->associate($users->random())->save(); }); }
/** * Run the database seeds. * * @return void */ public function run() { // Delete documents table DB::table('documents')->delete(); // Make documents array $documents = array(); // document 1 $documents[0] = array('name' => 'doc1', 'user_id' => App\User::all()->first()->id, 'created_at' => \Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => \Carbon\Carbon::now()->toDateTimeString()); DB::table('documents')->insert($documents); }
/** * Run the database seeds. * * @return void */ public function run() { // DB::table('users')->insert([["name" => "Jay Ravaliya", "email" => "*****@*****.**", "password" => md5("password"), "remember_token" => md5("password" . time())], ["name" => "Varun Shah", "email" => "*****@*****.**", "password" => md5("password"), "remember_token" => md5("password" . time())], ["name" => "Saurabh Palaspagar", "email" => "*****@*****.**", "password" => md5("password"), "remember_token" => md5("password" . time())], ["name" => "Pranav Patel", "email" => "*****@*****.**", "password" => md5("password"), "remember_token" => md5("password" . time())]]); DB::table('users')->insert([["name" => "Super User", "email" => "*****@*****.**", "password" => md5("password"), "remember_token" => md5("password" . time()), "admin_flag" => 1]]); foreach (App\User::all() as $user) { $user->touch(); $user->created_at = $user->updated_at; $user->save(); } }
public function run() { // Uncomment the below to wipe the table clean before populating DB::table('comments')->delete(); $posts = App\Post::all(); $users = App\User::all(); for ($i = 1; $i <= 3; $i++) { $comments = array(['body' => "Nice post!", 'user_id' => $i, 'commentable_id' => $i * 8 % 11 + 1, 'commentable_type' => 'App\\Post', 'created_at' => new DateTime(), 'updated_at' => new DateTime()], ['body' => "Agreed.", 'user_id' => $i, 'commentable_id' => $i * 8 % 11 + 2, 'commentable_type' => 'App\\Post', 'created_at' => new DateTime(), 'updated_at' => new DateTime()], ['body' => "No way!", 'user_id' => $i, 'commentable_id' => $i * 8 % 11 + 3, 'commentable_type' => 'App\\Post', 'created_at' => new DateTime(), 'updated_at' => new DateTime()], ['body' => "I guess...", 'user_id' => $i, 'commentable_id' => $i * 8 % 11 + 4, 'commentable_type' => 'App\\Post', 'created_at' => new DateTime(), 'updated_at' => new DateTime()]); // Uncomment the below to run the seeder DB::table('comments')->insert($comments); } }
/** * Run the database seeds. * * @return void */ public function run() { // create a user DB::table('users')->insert(['name' => 'arabyalhomsi', 'email' => '*****@*****.**', 'password' => Hash::make('aaa123')]); // create a user DB::table('users')->insert(['name' => 'ameralhomsi', 'email' => '*****@*****.**', 'password' => Hash::make('aaa123')]); // create a category App\Category::create(['title' => 'love']); App\Category::create(['title' => 'dance']); // create an article $article = new App\Article(['title' => 'arabylaohmsiasdas', 'body' => 'BlAb ABlAb AbBlAb Ab BlAb Abb', 'views' => 20]); $article2 = new App\Article(['title' => 'basdasd', 'body' => 'BlAb ABlAb asdasdasAbBlAb Ab BlAb Abb', 'views' => 30]); App\User::all()[0]->articles()->save($article); App\Category::all()[0]->articles()->save($article); App\Category::all()[1]->articles()->save($article); App\User::all()[0]->articles()->save($article2); App\Category::all()[0]->articles()->save($article2); App\Category::all()[1]->articles()->save($article2); }
/** * Run the database seeds. * * @return void */ public function run() { App\User::create(['name' => 'Admin', 'email' => '*****@*****.**', 'password' => bcrypt('s3cr3t'), 'remember_token' => str_random(10), 'status_id' => 1])->assignRole('admin'); App\User::create(['name' => 'demo', 'email' => '*****@*****.**', 'password' => bcrypt('demo'), 'remember_token' => str_random(10), 'status_id' => 1])->assignRole('demo'); factory(App\User::class, 6)->create()->each(function ($u) { $u->assignRole('admin'); }); factory(App\User::class, 5)->create()->each(function ($u) { $u->assignRole('staff'); }); factory(App\User::class, 10)->create()->each(function ($u) { $u->assignRole('mod'); }); factory(App\User::class, 80)->create()->each(function ($u) { $u->assignRole('user'); }); foreach (App\User::all() as $u) { App\Token::create(['user_id' => $u->id, 'amount' => 2]); } }
/** * A basic functional test example. * * @return void */ public function test_database() { $users = App\User::all(); foreach ($users as $user) { echo $user->id; } //Auth::loginUsingId(2); $response = $this->client->get('calendars'); //dd($response->getStatusCode()); //dd($this->client); //$this->assertEquals(200, $response->getStatusCode()); // $data = json_decode($response->getBody(true), true); //dd($this->client); //$response = $this->client->get('calendars'); //dd($response); //200 response //$response = $this->client->get($uri); //$this->assertEquals(200, $response->getStatusCode()); //$data = json_decode($response->getBody(true), true); //$this->seeInDatabase('calendar', ['id' => '2']); /*factory(App\Calendar::class, 20)->create() ->each(function($calendar) { $calendar->relatedItems()->save(factory('App\User')->make()); });*/ /* $users = factory(App\User::class, 3)->create() ->each(function($u){ $u->calendars()->save(factory('App\Calendar')->make()); });*/ /*$calendars = factory(App\Calendar::class)->create() ->each(function($u){ $u->user()->save(factory('App\User')->make()); });*/ //$user = factory(App\User::class)->create(); //$calendar = factory(App\Calendar::class)->make(); //$calendar->create(); //$calendar->user_id = $user->id; //dd($calendar->summary); //$calendar->create(); //$events = factory(App\Event::class, 2)->make(); //dd($calendars->toArray()); }
/** * Run the database seeds. * * @return void */ public function run() { // Generate users factory(App\User::class, 10)->create()->each(function (App\User $user) { $user->profileImage()->associate(factory(App\Image::class, 1)->make()); }); // Generate tags factory(App\Tag::class, 8)->create(); // Generate projects factory(App\Project::class, 16)->create()->each(function (App\Project $project) { // Associate with contributors and tags $project->tags()->saveMany(App\Tag::all()->random(random_int(2, 6))); $project->contributors()->saveMany(App\User::all()->random(2)); // Add content $project->colors()->saveMany(factory(App\Color::class, random_int(2, 5))->make()); $project->fonts()->saveMany(factory(App\Font::class, random_int(2, 3))->make()); $project->images()->saveMany(factory(App\Image::class, random_int(3, 5))->make()); $project->textures()->saveMany(factory(App\Texture::class, random_int(3, 5))->make()); }); // Generate comments factory(App\Comment::class, 20)->create(); // Generate notifications factory(App\Notification::class, 20)->create(); }
/** * Run the database seeds. * * @return void */ public function run() { //find user $users = App\User::all(); //make list //connect list with use foreach ($users as $user) { $list = new GroceryList(['name' => "My Shopping List"]); $list->user()->associate($user); //$user->save(); $list->save(); //$user->groceryLists()->save($list); $itemInfos = App\ItemInfo::all(); //create grocery list items associated with $list $pos = 0; foreach ($itemInfos as $itemInfo) { $pos++; $g = new GroceryListItem(['active' => true, 'qty' => 1, 'position' => $pos]); $g->groceryList()->associate($list); $g->itemInfo()->associate($itemInfo); $g->save(); } } }
| | Here is where you will register all of the routes in 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::get('/', function () { return view('welcome'); }); Route::group(['prefix' => 'api/v0.1'], function () { // Make sure the API is working. Route::get('/heartbeat', function () { return Response::json(["response" => "OK"])->header('Access-Control-Allow-Origin', '*'); }); Route::get('/docs', function (Request $request) { return view('docs', ['users' => App\User::all(), 'companies' => App\Company::with('user')->get(), 'request' => $request]); }); // User Management Routes Route::group(['prefix' => 'user'], function () { Route::post('/login', "UserManagementController@loginUser"); Route::post('/register', "UserManagementController@registerUser"); Route::group(['middleware' => ['customauth']], function () { Route::put('/edit', "UserManagementController@editUser"); Route::patch('/password', "UserManagementController@changePassword"); Route::post('/logout', "UserManagementController@logoutUser"); Route::delete('/deactivate', "UserManagementController@deactivateUser"); Route::get('/get', "UserManagementController@getUser"); }); }); // Chat Routes Route::group(['middleware' => ['customauth'], 'prefix' => 'chat'], function () {
<?php /* |-------------------------------------------------------------------------- | Model Factories |-------------------------------------------------------------------------- | | Here you may define all of your model factories. Model factories give | you a convenient way to create models for testing and seeding your | database. Just tell the factory how a default model should look. | */ // User Factory $factory->define(App\User::class, function (Faker\Generator $faker) { return ['name' => $faker->name, 'email' => $faker->email, 'password' => bcrypt(str_random(10)), 'remember_token' => str_random(10)]; }); // Post Factory $factory->define(App\Post::class, function (Faker\Generator $faker) { return ['title' => $faker->sentence(), 'short_story' => $faker->text(500), 'full_story' => $faker->text(2000), 'image' => $faker->imageUrl($width = 640, $height = 480), 'user_id' => App\User::all()->random(1)->id]; }); // Comment Factory $factory->define(App\Comment::class, function (Faker\Generator $faker) { return ['comment' => $faker->text(rand(100, 1000)), 'post_id' => App\Post::all()->random(1)->id, 'user_id' => App\User::all()->random(1)->id]; });
Route::get('rqxgq', function () { //只有在模型文件里设置 $dates 才可以直接使用Carbon类型 //自带的created_at和updated_at不受限制 也就是不放在数组里也没关系 $article = App\Article::find(1); return $article->published_at->getTimestamp(); }); /** * 序列号 */ Route::get('xlh', function () { $user = App\User::find(1); //return $user->toJson(); //return (string)$user; //隐藏属性这样是可以看见的 //dump($user->password); return App\User::all(); }); // 认证路由... Route::get('auth/login', 'Auth\\AuthController@getLogin'); Route::post('auth/login', 'Auth\\AuthController@postLogin'); Route::get('auth/logout', 'Auth\\AuthController@getLogout'); // 注册路由... Route::get('auth/register', 'Auth\\AuthController@getRegister'); Route::post('auth/register', 'Auth\\AuthController@postRegister'); Route::get('profile', ['middleware' => 'auth.basic', function () { echo '爱爱爱'; }]); /* * collect集合演示 */ Route::get("collect", function () {
Route::post('register', ['as' => 'post-register', 'uses' => 'Auth\\AuthController@postRegister']); Route::get('/{confirm}/{userToken}', ['as' => 'confirm', 'uses' => 'Auth\\AuthController@getConfirmSubscription']); Route::get('404', 'FrontController@notFound'); Route::get('/{reset}/', ['as' => 'reset', 'uses' => 'Auth\\PasswordController@getEmail']); Route::post('password-email', ['as' => 'password-email', 'uses' => 'Auth\\AuthController@postResetPassword']); Route::get('password/reset/{token}', 'Auth\\PasswordController@getReset'); Route::post('password/reset', ['as' => 'reset', 'uses' => 'Auth\\PasswordController@postReset']); Route::group(['middleware' => 'auth'], function () { Route::get('{dashboard}', ['as' => 'dashboard', 'uses' => 'UserController@dashboard']); }); Route::group(['prefix' => 'admin', 'middleware' => 'role:Super'], function () { Route::get('testmiddleware', function (\Illuminate\Http\Request $request) { dd($request->user()->roles()); return 'ea'; }); Route::get('{users}', 'UserController@users'); }); }); //pruebas API con vue.js get('api/users', function () { $users = App\User::all()->except(Auth::id()); foreach ($users as &$user) { $user['roles'] = $user->roles; } return $users; }); post('api/user/{id}', function ($id) { $user = App\User::findorFail($id); $user->is_active = Request::get('is_active'); return (int) $user->save(); });
<?php /* |-------------------------------------------------------------------------- | 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::get('/', function () { return view('home'); }); post('login', function (Illuminate\Http\Request $request) { if (Auth::attempt(['email' => $request->get('email'), 'password' => $request->get('password')])) { return response()->json(['success' => true, 'message' => 'Login successfully performed'], 200); } return response()->json(['success' => false, 'message' => 'Unable to login'], 401); }); Route::group(['middleware' => 'auth'], function () { post('logout', function () { Auth::logout(); return response()->json(['success' => true, 'message' => 'You logout with success'], 200); }); get('users', function () { $users = App\User::all(); return response()->json(['success' => 'true', 'message' => 'Loading users', 'data' => ['users' => $users->toJson()]], 200); }); });
$firs_name = $faker->firstName; $last_name = $faker->lastName; return ['identification' => $faker->unique()->numberBetween(5000000, 39999999), 'first_name' => $firs_name, 'last_name' => $last_name, 'avatar' => 'vendor/AdminTheme/images/avatar/default.png', 'type' => $faker->randomElement(['teacher', 'student']), 'email' => $faker->unique()->email, 'password' => '123456']; }); $factory->define(App\Course::class, function ($faker) { return ['title' => $faker->sentence(3), 'description' => $faker->paragraph(10), 'image' => $faker->imageUrl(660, 260), 'user_id' => App\User::all()->random()->id]; }); $factory->define(App\Unit::class, function ($faker) { return ['pos' => $faker->randomNumber(1), 'title' => $faker->sentence(5), 'description' => $faker->paragraph(10), 'image' => $faker->imageUrl(660, 260), 'user_id' => App\User::all()->random()->id, 'course_id' => App\Course::all()->random()->id]; }); $factory->define(App\Lesson::class, function ($faker) { return ['pos' => $faker->randomNumber(1), 'title' => $faker->sentence(5), 'content' => $faker->paragraph(10), 'user_id' => App\User::all()->random()->id, 'unit_id' => App\Unit::all()->random()->id]; }); $factory->define(App\Question::class, function ($faker) { return ['title' => $faker->sentence(2) . '?', 'unit_id' => App\Unit::all()->random()->id, 'user_id' => App\User::all()->random()->id]; }); $factory->define(App\Answer::class, function ($faker) { return ['content' => $faker->sentence(5), 'correct' => rand(0, 1), 'question_id' => App\Question::all()->random()->id, 'user_id' => App\User::all()->random()->id]; }); $factory->define(App\Comment::class, function ($faker) { return ['content' => $faker->paragraph(5), 'user_id' => App\User::all()->random()->id, 'lesson_id' => App\Lesson::all()->random()->id]; }); $factory->define(App\Reply::class, function ($faker) { return ['content' => $faker->paragraph(5), 'user_id' => App\User::all()->random()->id, 'comment_id' => App\Comment::all()->random()->id]; }); $factory->define(App\Evaluation::class, function ($faker) { return ['value' => $faker->numberBetween(15, 20), 'min_value' => $faker->numberBetween(50, 85), 'max_question' => $faker->numberBetween(5, 6), 'unit_id' => App\Unit::all()->random()->id, 'user_id' => App\User::all()->random()->id]; }); $factory->define(App\CourseUser::class, function ($faker) { return ['course_id' => App\Course::all()->random()->id, 'user_id' => App\User::all()->random()->id]; });
<?php /* |-------------------------------------------------------------------------- | Model Factories |-------------------------------------------------------------------------- | | Here you may define all of your model factories. Model factories give | you a convenient way to create models for testing and seeding your | database. Just tell the factory how a default model should look. | */ $factory->define(App\User::class, function ($faker) { return ['name' => $faker->userName, 'email' => $faker->email, 'password' => bcrypt('password'), 'remember_token' => str_random(10)]; }); $factory->define(App\Problem::class, function ($faker) { return ['title' => $faker->company, 'description' => join("\n\n", $faker->paragraphs($faker->numberBetween(1, 5))), 'input' => $faker->paragraph, 'output' => $faker->paragraph, 'sample_input' => $faker->postcode, 'sample_output' => join("\n", $faker->words($faker->numberBetween(1, 10))), 'time_limit' => $faker->numberBetween(1, 5), 'memory_limit' => $faker->numberBetween(1, 5) * 128, 'is_special' => $faker->boolean(15), 'status' => $faker->boolean(85)]; }); $factory->define(App\Solution::class, function ($faker) { return ['lang_id' => App\Language::all()->random()->id, 'problem_id' => App\Problem::all()->random()->id, 'user_id' => App\User::all()->random()->id, 'result_id' => App\Result::all()->random()->id, 'time' => $faker->numberBetween(1, 249) * 4, 'memory' => $faker->numberBetween(0, 1024) * 4, 'size' => $faker->numberBetween(20, 1200), 'is_hidden' => $faker->boolean(20), 'is_published' => $faker->boolean(95)]; });
/* |-------------------------------------------------------------------------- | Model Factories |-------------------------------------------------------------------------- | | Here you may define all of your model factories. Model factories give | you a convenient way to create models for testing and seeding your | database. Just tell the factory how a default model should look. | */ $factory->define(App\User::class, function (Faker\Generator $faker) { $faker = Faker\Factory::create('pt_BR'); return ['name' => $faker->name, 'email' => $faker->email, 'password' => bcrypt(str_random(10)), 'rule' => 'user', 'remember_token' => str_random(10)]; }); $factory->define(App\CustomerSize::class, function (Faker\Generator $faker) { $faker = Faker\Factory::create('pt_BR'); return ['description' => $faker->word]; }); $factory->define(App\Difficulty::class, function (Faker\Generator $faker) { $faker = Faker\Factory::create('pt_BR'); return ['description' => $faker->word]; }); $factory->define(App\Importance::class, function (Faker\Generator $faker) { $faker = Faker\Factory::create('pt_BR'); return ['description' => $faker->word]; }); $factory->define(App\Improvement::class, function (Faker\Generator $faker) { $faker = Faker\Factory::create('pt_BR'); return ['description' => $faker->realText($maxNbChars = 200, $indexSize = 2), 'product' => $faker->randomElement($array = array('Educacional', 'Processo Seletivo', 'Testis', 'Biblios', 'Financeiro')), 'user_id' => App\User::all()->random()->id, 'customerSize_id' => App\CustomerSize::all()->random()->id, 'importance_id' => App\Importance::all()->random()->id, 'difficulty_id' => App\Difficulty::all()->random()->id]; });
/** * get user function * * @return json response */ public function get_users() { $users = App\User::all(); return response()->json(json_encode($users), 200); }
<?php /* |-------------------------------------------------------------------------- | Model Factories |-------------------------------------------------------------------------- | | Here you may define all of your model factories. Model factories give | you a convenient way to create models for testing and seeding your | database. Just tell the factory how a default model should look. | */ $factory->define(App\User::class, function (Faker\Generator $faker) { return ['name' => $faker->name, 'email' => $faker->email, 'password' => bcrypt(str_random(10)), 'remember_token' => str_random(10)]; }); $factory->define(App\Post::class, function (Faker\Generator $faker) { return ['title' => $faker->realText(rand(10, 18), true), 'author' => App\User::all()->random()->id, 'body' => $faker->paragraphs(rand(2, 5), true)]; });
|-------------------------------------------------------------------------- | | Here you may define all of your model factories. Model factories give | you a convenient way to create models for testing and seeding your | database. Just tell the factory how a default model should look. | */ $factory->define(App\User::class, function (Faker\Generator $faker) { return ['username' => $faker->userName, 'name' => $faker->name, 'email' => $faker->email, 'password' => bcrypt(str_random(10)), 'remember_token' => str_random(10)]; }); $factory->define(App\Task::class, function (Faker\Generator $faker) { $users = App\User::all()->lists('id')->all(); return ['name' => $faker->realText(30), 'description' => $faker->realText(200), 'extra_info' => $faker->realText(200), 'date_expected' => $faker->dateTime('+ 1 month'), 'date_finished' => $faker->dateTime('+ 1 month'), 'duration_expected' => mt_rand(1, 16) * 15, 'duration_finished' => mt_rand(1, 16) * 15, 'done' => $faker->boolean(), 'status' => rand(0, 6), 'asignees' => $faker->randomElements($users, mt_rand(1, 11))]; }); $factory->define(App\Job::class, function (Faker\Generator $faker) { $users = App\User::all()->lists('id')->all(); $tasks = App\Task::all()->lists('id')->all(); $deliverables = array(); for ($i = 0; $i < mt_rand(2, 7); $i++) { array_push($deliverables, 1); } $sessions = array(); for ($i = 0; $i < mt_rand(2, 7); $i++) { array_push($sessions, 1); } $materials = array(); for ($i = 0; $i < mt_rand(2, 7); $i++) { array_push($materials, 1); } $payments = array(); for ($i = 0; $i < mt_rand(2, 7); $i++) {
return ['user_id' => $faker->randomElement($usrArray), 'category_id' => $faker->randomElement($ctgArray), 'description' => $faker->paragraph]; }); $factory->define(App\SocialActivity::class, function (Faker\Generator $faker) { $usrArray = App\User::all()->lists('id')->toArray(); $act = ['followed', 'unfollowed']; return ['subject_id' => $faker->randomElement($usrArray), 'object_id' => $faker->randomElement($usrArray), 'activity' => $faker->randomElement($act)]; }); $factory->define(App\Recruitment::class, function (Faker\Generator $faker) { $prjArray = App\Project::all()->lists('id')->toArray(); return ['project_id' => $faker->randomElement($prjArray)]; }); $factory->define(App\Roadmap::class, function (Faker\Generator $faker) { $prjArray = App\Project::all()->lists('id')->toArray(); return ['project_id' => $faker->randomElement($prjArray), 'description' => $faker->paragraph]; }); $factory->define(App\Goal::class, function (Faker\Generator $faker) { $rdmArray = App\Roadmap::all()->lists('id')->toArray(); return ['roadmap_id' => $faker->randomElement($rdmArray), 'description' => $faker->paragraph]; }); $factory->define(App\Task::class, function (Faker\Generator $faker) { //masih harus diubah spy dapetnya cmn user yg terlibat ke project $usrArray = App\User::all()->lists('id')->toArray(); $glArray = App\Goal::all()->lists('id')->toArray(); $status = ['Completed', 'Ongoing']; return ['goal_id' => $faker->randomElement($glArray), 'user_id' => $faker->randomElement($usrArray), 'status' => $faker->randomElement($status)]; }); $factory->define(App\RecruitmentTransaction::class, function (Faker\Generator $faker) { $rcArray = App\Recruitment::all()->lists('id')->toArray(); $usrArray = App\Recruitment::all()->lists('id')->toArray(); return ['recruitment_id' => $faker->randomElement($rcArray), 'user_id' => $faker->randomElement($usrArray)]; });
//Ask to Resend a Verification Email for Activation Route::get('/resendEmail', 'Auth\\AuthController@resendEmail'); // Route::get('{link?}', ['as' => 'reflink', 'uses' => 'LinkController@getRefLink']); Route::get('materialized', function () { $users = App\User::latest()->get(); $int = App\User::all()->count() * 5; $rfnbonus = intval($int); return view('materialized', compact('users', 'rfnbonus')); }); Route::get('fire', function () { // this fires the event event(new App\Events\IncreaseRfnBonus()); return "Event Fired!"; }); Route::get('api/rfnbonus', function () { $rfnbonus = App\User::all()->count() * 5; return $rfnbonus; }); //test route for broadcasting in the NewsBar Route::get('sender', function () { $data = ['event' => 'UserSignedUp', 'data' => ['display_name' => 'chill', 'created_at' => '2011-12-17T09:24:17Z']]; // Use this To Fire User Info In NewsBar // This Can Use the test-chanel in UserHasRegistered Event PHPRedis::publish('rfn-chanel', json_encode($data)); return "User Signed Up!"; }); Route::get('receiver', function () { return view('receiver'); }); //test route for Redis set and get key Route::get('message', function () {
<?php /* |-------------------------------------------------------------------------- | Model Factories |-------------------------------------------------------------------------- | | Here you may define all of your model factories. Model factories give | you a convenient way to create models for testing and seeding your | database. Just tell the factory how a default model should look. | */ $factory->define(App\User::class, function (Faker\Generator $faker) { return ['name' => $faker->name, 'email' => $faker->email, 'password' => bcrypt(str_random(10)), 'remember_token' => str_random(10)]; }); $factory->define(App\Post::class, function (Faker\Generator $faker) { return ['title' => $faker->sentence, 'body' => $faker->paragraph, 'user_id' => App\User::all()->random()->id]; });
/** * Run the database seeds. * * @return void */ public function run() { /* * Prepare seeding */ $faker = Faker::create(); if (config('database.default') != 'sqlite') { DB::statement('SET FOREIGN_KEY_CHECKS=0'); } Model::unguard(); /* * Seeding users table */ App\User::truncate(); factory(App\User::class)->create(['name' => 'John Doe', 'email' => '*****@*****.**', 'password' => bcrypt('password')]); factory(App\User::class, 9)->create(); $this->command->info('users table seeded'); /** * Seeding roles table */ Bican\Roles\Models\Role::truncate(); DB::table('role_user')->truncate(); $adminRole = Bican\Roles\Models\Role::create(['name' => 'Admin', 'slug' => 'admin']); $memberRole = Bican\Roles\Models\Role::create(['name' => 'Member', 'slug' => 'member']); App\User::where('email', '!=', '*****@*****.**')->get()->map(function ($user) use($memberRole) { $user->attachRole($memberRole); }); App\User::whereEmail('*****@*****.**')->get()->map(function ($user) use($adminRole) { $user->attachRole($adminRole); }); $this->command->info('roles table seeded'); /* * Seeding articles table */ App\Article::truncate(); $users = App\User::all(); $users->each(function ($user) use($faker) { $user->articles()->save(factory(App\Article::class)->make()); $user->articles()->save(factory(App\Article::class)->make()); }); $this->command->info('articles table seeded'); /** * Seeding comments table */ App\Comment::truncate(); $articles = App\Article::all(); $articles->each(function ($article) use($faker, $users) { $article->comments()->save(factory(App\Comment::class)->make(['author_id' => $faker->randomElement($users->lists('id')->toArray())])); }); $this->command->info('comments table seeded'); /* * Seeding tags table */ App\Tag::truncate(); DB::table('article_tag')->truncate(); $rawTags = ['General', 'Laravel', 'Lumen', 'Eloquent', 'Servers', 'Tips', 'Lesson Feedback']; foreach ($rawTags as $tag) { App\Tag::create(['name' => $tag, 'slug' => str_slug($tag)]); } $tags = App\Tag::all(); foreach ($articles as $article) { $article->tags()->attach($faker->randomElements($tags->lists('id')->toArray(), $faker->randomElement([1, 2, 3]))); } $this->command->info('tags table seeded'); /* * Seeding attachments table */ App\Attachment::truncate(); if (!File::isDirectory(attachment_path())) { File::deleteDirectory(attachment_path(), true); } $articles->each(function ($article) use($faker) { $article->attachments()->save(factory(App\Attachment::class)->make()); }); $files = App\Attachment::lists('name'); if (!File::isDirectory(attachment_path())) { File::makeDirectory(attachment_path(), 777, true); } foreach ($files as $file) { File::put(attachment_path($file), ''); } $this->command->info('attachments table seeded'); /** * Close seeding */ Model::reguard(); if (config('database.default') != 'sqlite') { DB::statement('SET FOREIGN_KEY_CHECKS=1'); } }
private function beTheUser() { $this->be(App\User::all()->first()); }
'name' => 'Admin', 'email' => '*****@*****.**', 'password' => bcrypt(1234), 'api_token' => 123, ]); }); */ // This for getting security key // =========================================================== Route::post('api/v1/login', 'Auth\\AuthController@login'); // =========================================================== Route::group(['prefix' => 'api/v1/auth', 'namespace' => 'Auth', 'middleware' => 'auth.api'], function () { Route::get('cektoken', 'AuthController@cekToken'); Route::get('question', 'AuthController@question'); Route::get('user/{id?}', function ($id = null) { if ($id == null) { $user = App\User::all(); } else { $user = App\User::find($id); } return Response::json(['data' => $user], 200); }); Route::post('user', 'AuthController@user'); }); Route::group(['prefix' => 'api/v1', 'namespace' => 'Api', 'middleware' => 'auth'], function () { Route::post('index', 'SystemController@index'); }); // Route::group(['middleware' => 'web'], function () { // Route::auth(); // Route::get('/home', 'HomeController@index'); // });