Beispiel #1
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     for ($i = 4; $i < 20; $i++) {
         $users[] = ['email' => 'demo' . $i . '@example.com', 'password' => 'demo123', 'username' => 'AAA00' . $i, 'username_upline' => 'AAA001', 'first_name' => 'Member ke-' . $i];
     }
     //  		$users = [
     // 	[
     // 		'email'    => '*****@*****.**',
     // 		'password' => 'demo123',
     // 		'username' => 'AAA004',
     // 		'username_upline' => 'AAA001',
     // 	],
     // 	[
     // 		'email'    => '*****@*****.**',
     // 		'password' => 'demo123',
     // 		'username' => 'AAA005',
     // 		'username_upline' => 'AAA001',
     // 	],
     // 	[
     // 		'email'    => '*****@*****.**',
     // 		'password' => 'demo123',
     // 		'username' => 'AAA006',
     // 		'username_upline' => 'AAA001',
     // 	],
     // ];
     $role = Sentinel::findRoleByName('Members');
     //dibuat dulu bila blm ada Role nya
     foreach ($users as $user) {
         $newUser = Sentinel::registerAndActivate($user);
         //$newUser = Sentinel::findById($user->id);
         $role->users()->attach($newUser);
     }
     Model::reguard();
 }
Beispiel #2
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     // Hapus isi table users, groups, users_groups dan throttle
     DB::table('role_users')->delete();
     DB::table('roles')->delete();
     DB::table('users')->delete();
     DB::table('throttle')->delete();
     //create role administrator
     $role = Sentinel::getRoleRepository()->createModel()->create(['name' => 'Administrators', 'slug' => 'administrators']);
     //create role regulars
     $role = Sentinel::getRoleRepository()->createModel()->create(['name' => 'Regulars', 'slug' => 'regulars']);
     //create user admin and activate
     $credentials = ['email' => '*****@*****.**', 'password' => 'enter'];
     $user = Sentinel::registerAndActivate($credentials);
     //create user user and activate
     $credentials = ['email' => '*****@*****.**', 'password' => 'enter'];
     $user = Sentinel::registerAndActivate($credentials);
     // assign user to a role
     $credentials = ['login' => '*****@*****.**'];
     $user = Sentinel::findByCredentials($credentials);
     //$user = Sentinel::findById(1);
     $role = Sentinel::findRoleByName('Administrators');
     $role->users()->attach($user);
     $credentials = ['login' => '*****@*****.**'];
     $user = Sentinel::findByCredentials($credentials);
     //$user = Sentinel::findById(1);
     $role = Sentinel::findRoleByName('Regulars');
     $role->users()->attach($user);
 }
Beispiel #3
0
 public function run()
 {
     # Cats Seeder
     DB::table('cats')->delete();
     DB::table('cats')->insert([['title' => 'وب سایت', 'parent' => 0], ['title' => 'طراحی', 'parent' => 0], ['title' => 'طراحی سایت', 'parent' => 1], ['title' => 'رابط کاربری', 'parent' => 1], ['title' => 'قالب سایت', 'parent' => 1], ['title' => 'لوگو', 'parent' => 2], ['title' => 'لوگوتایپ', 'parent' => 2], ['title' => 'ست اداری', 'parent' => 2], ['title' => 'کارت ویزیت', 'parent' => 2], ['title' => 'بروشور', 'parent' => 2]]);
     $this->command->info('Cats seeded!');
     # Posts Seeder
     DB::table('posts')->delete();
     DB::table('posts')->insert([['title' => 'شرکت ایرانیان گرافیک', 'description' => 'کـامـت از افرادی با تجــربه و علاقــه مــند به طراحــی تـشـکیل شده است کـه هدف اصـلی این گــروه طراحـی و توسعه وب با بـهره گـیری از بـروزتــرین نـرم افزارها و کــدها می باشد، هـمچنین این گـروه تمام تمرکز خود را صرف طراحی و توسـعه وب مـتناسب با نیاز مشــتری کرده است. ما معتـقدیم که ایــده ها مــی توانند از هر جـایی یا هر شـخصی بوجود بیایند واین اصل به ما کمک می کند تا تعریف دیگری از قدرت طراحی و توسعه وب بوجود بیاوریم !', 'smalldescription' => 'گروه کامت با طراحی هوشمندانه، ساخت بانک های اطلاعاتی بهینه و بهره مندی از آخرین نسخه پی اچ پی و فریمورک هایی چون لاراول، ساخت هسته ای قدرتمند، سریع و ایمن را با توجه به استانداردهای روز دنیا برای شما فراهم می نماید.', 'link' => 'http://google.com/', 'cat_id' => 3, 'thumb' => 'roundicons.png', 'image' => 'roundicons-free.png'], ['title' => 'گروه صنعتی ایران تکنیک', 'description' => 'کـامـت از افرادی با تجــربه و علاقــه مــند به طراحــی تـشـکیل شده است کـه هدف اصـلی این گــروه طراحـی و توسعه وب با بـهره گـیری از بـروزتــرین نـرم افزارها و کــدها می باشد، هـمچنین این گـروه تمام تمرکز خود را صرف طراحی و توسـعه وب مـتناسب با نیاز مشــتری کرده است. ما معتـقدیم که ایــده ها مــی توانند از هر جـایی یا هر شـخصی بوجود بیایند واین اصل به ما کمک می کند تا تعریف دیگری از قدرت طراحی و توسعه وب بوجود بیاوریم !', 'smalldescription' => 'گروه کامت با طراحی هوشمندانه، ساخت بانک های اطلاعاتی بهینه و بهره مندی از آخرین نسخه پی اچ پی و فریمورک هایی چون لاراول، ساخت هسته ای قدرتمند، سریع و ایمن را با توجه به استانداردهای روز دنیا برای شما فراهم می نماید.', 'link' => '', 'cat_id' => 9, 'thumb' => 'startup-framework-preview.png', 'image' => 'startup-framework-preview.png'], ['title' => 'وب سایت ما بالاخره تمام شد', 'description' => 'کـامـت از افرادی با تجــربه و علاقــه مــند به طراحــی تـشـکیل شده است کـه هدف اصـلی این گــروه طراحـی و توسعه وب با بـهره گـیری از بـروزتــرین نـرم افزارها و کــدها می باشد، هـمچنین این گـروه تمام تمرکز خود را صرف طراحی و توسـعه وب مـتناسب با نیاز مشــتری کرده است. ما معتـقدیم که ایــده ها مــی توانند از هر جـایی یا هر شـخصی بوجود بیایند واین اصل به ما کمک می کند تا تعریف دیگری از قدرت طراحی و توسعه وب بوجود بیاوریم !', 'smalldescription' => 'گروه کامت با طراحی هوشمندانه، ساخت بانک های اطلاعاتی بهینه و بهره مندی از آخرین نسخه پی اچ پی و فریمورک هایی چون لاراول، ساخت هسته ای قدرتمند، سریع و ایمن را با توجه به استانداردهای روز دنیا برای شما فراهم می نماید.', 'link' => 'http://google.com/', 'cat_id' => 3, 'thumb' => 'dreams.png', 'image' => 'dreams.png'], ['title' => 'یک تست واقعی !', 'description' => 'کـامـت از افرادی با تجــربه و علاقــه مــند به طراحــی تـشـکیل شده است کـه هدف اصـلی این گــروه طراحـی و توسعه وب با بـهره گـیری از بـروزتــرین نـرم افزارها و کــدها می باشد، هـمچنین این گـروه تمام تمرکز خود را صرف طراحی و توسـعه وب مـتناسب با نیاز مشــتری کرده است. ما معتـقدیم که ایــده ها مــی توانند از هر جـایی یا هر شـخصی بوجود بیایند واین اصل به ما کمک می کند تا تعریف دیگری از قدرت طراحی و توسعه وب بوجود بیاوریم !', 'smalldescription' => 'گروه کامت با طراحی هوشمندانه، ساخت بانک های اطلاعاتی بهینه و بهره مندی از آخرین نسخه پی اچ پی و فریمورک هایی چون لاراول، ساخت هسته ای قدرتمند، سریع و ایمن را با توجه به استانداردهای روز دنیا برای شما فراهم می نماید.', 'link' => '', 'cat_id' => 6, 'thumb' => 'dreams-preview.png', 'image' => 'dreams-preview.png'], ['title' => 'کافل', 'description' => 'کـامـت از افرادی با تجــربه و علاقــه مــند به طراحــی تـشـکیل شده است کـه هدف اصـلی این گــروه طراحـی و توسعه وب با بـهره گـیری از بـروزتــرین نـرم افزارها و کــدها می باشد، هـمچنین این گـروه تمام تمرکز خود را صرف طراحی و توسـعه وب مـتناسب با نیاز مشــتری کرده است. ما معتـقدیم که ایــده ها مــی توانند از هر جـایی یا هر شـخصی بوجود بیایند واین اصل به ما کمک می کند تا تعریف دیگری از قدرت طراحی و توسعه وب بوجود بیاوریم !', 'smalldescription' => 'گروه کامت با طراحی هوشمندانه، ساخت بانک های اطلاعاتی بهینه و بهره مندی از آخرین نسخه پی اچ پی و فریمورک هایی چون لاراول، ساخت هسته ای قدرتمند، سریع و ایمن را با توجه به استانداردهای روز دنیا برای شما فراهم می نماید.', 'link' => 'http://google.com/', 'cat_id' => 8, 'thumb' => 'roundicons.png', 'image' => 'roundicons-free.png'], ['title' => 'شرکت ایرانیان گرافیک', 'description' => 'کـامـت از افرادی با تجــربه و علاقــه مــند به طراحــی تـشـکیل شده است کـه هدف اصـلی این گــروه طراحـی و توسعه وب با بـهره گـیری از بـروزتــرین نـرم افزارها و کــدها می باشد، هـمچنین این گـروه تمام تمرکز خود را صرف طراحی و توسـعه وب مـتناسب با نیاز مشــتری کرده است. ما معتـقدیم که ایــده ها مــی توانند از هر جـایی یا هر شـخصی بوجود بیایند واین اصل به ما کمک می کند تا تعریف دیگری از قدرت طراحی و توسعه وب بوجود بیاوریم !', 'smalldescription' => 'گروه کامت با طراحی هوشمندانه، ساخت بانک های اطلاعاتی بهینه و بهره مندی از آخرین نسخه پی اچ پی و فریمورک هایی چون لاراول، ساخت هسته ای قدرتمند، سریع و ایمن را با توجه به استانداردهای روز دنیا برای شما فراهم می نماید.', 'link' => 'http://google.com/', 'cat_id' => 3, 'thumb' => 'roundicons.png', 'image' => 'roundicons-free.png'], ['title' => 'گروه صنعتی ایران تکنیک', 'description' => 'کـامـت از افرادی با تجــربه و علاقــه مــند به طراحــی تـشـکیل شده است کـه هدف اصـلی این گــروه طراحـی و توسعه وب با بـهره گـیری از بـروزتــرین نـرم افزارها و کــدها می باشد، هـمچنین این گـروه تمام تمرکز خود را صرف طراحی و توسـعه وب مـتناسب با نیاز مشــتری کرده است. ما معتـقدیم که ایــده ها مــی توانند از هر جـایی یا هر شـخصی بوجود بیایند واین اصل به ما کمک می کند تا تعریف دیگری از قدرت طراحی و توسعه وب بوجود بیاوریم !', 'smalldescription' => 'گروه کامت با طراحی هوشمندانه، ساخت بانک های اطلاعاتی بهینه و بهره مندی از آخرین نسخه پی اچ پی و فریمورک هایی چون لاراول، ساخت هسته ای قدرتمند، سریع و ایمن را با توجه به استانداردهای روز دنیا برای شما فراهم می نماید.', 'link' => '', 'cat_id' => 9, 'thumb' => 'startup-framework-preview.png', 'image' => 'startup-framework-preview.png'], ['title' => 'وب سایت ما بالاخره تمام شد', 'description' => 'کـامـت از افرادی با تجــربه و علاقــه مــند به طراحــی تـشـکیل شده است کـه هدف اصـلی این گــروه طراحـی و توسعه وب با بـهره گـیری از بـروزتــرین نـرم افزارها و کــدها می باشد، هـمچنین این گـروه تمام تمرکز خود را صرف طراحی و توسـعه وب مـتناسب با نیاز مشــتری کرده است. ما معتـقدیم که ایــده ها مــی توانند از هر جـایی یا هر شـخصی بوجود بیایند واین اصل به ما کمک می کند تا تعریف دیگری از قدرت طراحی و توسعه وب بوجود بیاوریم !', 'smalldescription' => 'گروه کامت با طراحی هوشمندانه، ساخت بانک های اطلاعاتی بهینه و بهره مندی از آخرین نسخه پی اچ پی و فریمورک هایی چون لاراول، ساخت هسته ای قدرتمند، سریع و ایمن را با توجه به استانداردهای روز دنیا برای شما فراهم می نماید.', 'link' => 'http://google.com/', 'cat_id' => 3, 'thumb' => 'dreams.png', 'image' => 'dreams.png'], ['title' => 'یک تست واقعی !', 'description' => 'کـامـت از افرادی با تجــربه و علاقــه مــند به طراحــی تـشـکیل شده است کـه هدف اصـلی این گــروه طراحـی و توسعه وب با بـهره گـیری از بـروزتــرین نـرم افزارها و کــدها می باشد، هـمچنین این گـروه تمام تمرکز خود را صرف طراحی و توسـعه وب مـتناسب با نیاز مشــتری کرده است. ما معتـقدیم که ایــده ها مــی توانند از هر جـایی یا هر شـخصی بوجود بیایند واین اصل به ما کمک می کند تا تعریف دیگری از قدرت طراحی و توسعه وب بوجود بیاوریم !', 'smalldescription' => 'گروه کامت با طراحی هوشمندانه، ساخت بانک های اطلاعاتی بهینه و بهره مندی از آخرین نسخه پی اچ پی و فریمورک هایی چون لاراول، ساخت هسته ای قدرتمند، سریع و ایمن را با توجه به استانداردهای روز دنیا برای شما فراهم می نماید.', 'link' => '', 'cat_id' => 6, 'thumb' => 'dreams-preview.png', 'image' => 'dreams-preview.png'], ['title' => 'کافل', 'description' => 'کـامـت از افرادی با تجــربه و علاقــه مــند به طراحــی تـشـکیل شده است کـه هدف اصـلی این گــروه طراحـی و توسعه وب با بـهره گـیری از بـروزتــرین نـرم افزارها و کــدها می باشد، هـمچنین این گـروه تمام تمرکز خود را صرف طراحی و توسـعه وب مـتناسب با نیاز مشــتری کرده است. ما معتـقدیم که ایــده ها مــی توانند از هر جـایی یا هر شـخصی بوجود بیایند واین اصل به ما کمک می کند تا تعریف دیگری از قدرت طراحی و توسعه وب بوجود بیاوریم !', 'smalldescription' => 'گروه کامت با طراحی هوشمندانه، ساخت بانک های اطلاعاتی بهینه و بهره مندی از آخرین نسخه پی اچ پی و فریمورک هایی چون لاراول، ساخت هسته ای قدرتمند، سریع و ایمن را با توجه به استانداردهای روز دنیا برای شما فراهم می نماید.', 'link' => 'http://google.com/', 'cat_id' => 8, 'thumb' => 'roundicons.png', 'image' => 'roundicons-free.png']]);
     $this->command->info('Posts seeded!');
     # Role Seeder
     DB::table('roles')->delete();
     Sentinel::getRoleRepository()->createModel()->create(['name' => 'users', 'slug' => 'users']);
     Sentinel::getRoleRepository()->createModel()->create(['name' => 'admins', 'slug' => 'admins']);
     $this->command->info('Roles seeded!');
     # User Seeder
     DB::table('users')->delete();
     Sentinel::registerAndActivate(['email' => '*****@*****.**', 'password' => 'user123', 'first_name' => 'علی', 'last_name' => 'شفاعت']);
     Sentinel::registerAndActivate(['email' => '*****@*****.**', 'password' => 'admin123', 'first_name' => 'مجید', 'last_name' => 'نورعلی', 'photo' => 'majid.jpg', 'cover' => 'majid.jpg']);
     $this->command->info('Users seeded!');
     # User Role Seeder
     DB::table('role_users')->delete();
     $userUser = Sentinel::findByCredentials(['login' => '*****@*****.**']);
     $adminUser = Sentinel::findByCredentials(['login' => '*****@*****.**']);
     $userRole = Sentinel::findRoleByName('users');
     $adminRole = Sentinel::findRoleByName('admins');
     $userRole->users()->attach($userUser);
     $adminRole->users()->attach($adminUser);
     $this->command->info('Users assigned to roles seeded!');
     # Resume Seeder
     DB::table('resumes')->delete();
     DB::table('resumes')->insert([['user_id' => 1, 'tel' => '09128303586', 'duty' => 'معافیت پزشکی', 'rel' => false, 'jobtitle' => 'طراح و برنامه نویس وب', 'bio' => 'کـامـت از افرادی با تجــربه و علاقــه مــند به طراحــی تـشـکیل شده است کـه هدف اصـلی این گــروه طراحـی و توسعه وب با بـهره گـیری از بـروزتــرین نـرم افزارها و کــدها می باشد، هـمچنین این گـروه تمام تمرکز خود را صرف طراحی و توسـعه وب مـتناسب با نیاز مشــتری کرده است. ما معتـقدیم که ایــده ها مــی توانند از هر جـایی یا هر شـخصی بوجود بیایند واین اصل به ما کمک می کند تا تعریف دیگری از قدرت طراحی و توسعه وب بوجود بیاوریم !', 'address' => 'رسالت، مجیدیه شمالی، 16 متری دوم، کوچه شاکری', 'birth' => '1989-02-18', 'gender' => false], ['user_id' => 2, 'tel' => '09362859493', 'duty' => 'پایان خدمت', 'rel' => false, 'jobtitle' => 'طراح و برنامه نویس وب', 'bio' => 'کـامـت از افرادی با تجــربه و علاقــه مــند به طراحــی تـشـکیل شده است کـه هدف اصـلی این گــروه طراحـی و توسعه وب با بـهره گـیری از بـروزتــرین نـرم افزارها و کــدها می باشد، هـمچنین این گـروه تمام تمرکز خود را صرف طراحی و توسـعه وب مـتناسب با نیاز مشــتری کرده است. ما معتـقدیم که ایــده ها مــی توانند از هر جـایی یا هر شـخصی بوجود بیایند واین اصل به ما کمک می کند تا تعریف دیگری از قدرت طراحی و توسعه وب بوجود بیاوریم !', 'address' => 'رسالت، مجیدیه شمالی، 16 متری دوم، کوچه علی بخشی', 'birth' => '1986-05-10', 'gender' => false]]);
     $this->command->info('Resumes seeded!');
     # Lang Seeder
     DB::table('langs')->delete();
     DB::table('langs')->insert([['user_id' => 1, 'title' => 'انگلیسی', 'score' => 7], ['user_id' => 1, 'title' => 'آلمانی', 'score' => 5], ['user_id' => 2, 'title' => 'انگلیسی', 'score' => 7.5]]);
     $this->command->info('Langs seeded!');
     # Xp Seeder
     DB::table('xps')->delete();
     DB::table('xps')->insert([['user_id' => 1, 'startyear' => '1998-01-01', 'endyear' => '2001-01-01', 'company' => 'ایرانیان گرافیک'], ['user_id' => 1, 'startyear' => '2010-01-01', 'endyear' => '2011-01-01', 'company' => 'گروه طراحی و توسعه کامت'], ['user_id' => 1, 'startyear' => '2012-01-01', 'endyear' => '2013-01-01', 'company' => 'خانه عکس ایران'], ['user_id' => 2, 'startyear' => '2014-01-01', 'endyear' => '2015-01-01', 'company' => 'خانه تبلیغات مرکزی'], ['user_id' => 2, 'startyear' => '2006-01-01', 'endyear' => '2008-01-01', 'company' => 'ایرانیان گرافیک'], ['user_id' => 2, 'startyear' => '2008-01-01', 'endyear' => '2011-01-01', 'company' => 'گروه کافل']]);
     $this->command->info('Xps seeded!');
     # Edu Seeder
     DB::table('edus')->delete();
     DB::table('edus')->insert([['user_id' => 1, 'startyear' => '1998-01-01', 'endyear' => '2001-01-01', 'degree' => 'دیپلم', 'branch' => 'ریاضی', 'uni' => 'مدرسه فاتح', 'score' => 17.8], ['user_id' => 1, 'startyear' => '2010-01-01', 'endyear' => '2014-01-01', 'degree' => 'دکترای', 'branch' => 'صنایع', 'uni' => 'صنعتی شریف', 'score' => 14.72], ['user_id' => 2, 'startyear' => '1990-01-01', 'endyear' => '2001-01-01', 'degree' => 'فوق لیسانس', 'branch' => 'کامپیوتر نرم افزار', 'uni' => 'دانشگاه شمال آمل', 'score' => 19.8], ['user_id' => 2, 'startyear' => '2014-01-01', 'endyear' => '2015-01-01', 'degree' => 'دکترای', 'branch' => 'نرم افزار', 'uni' => 'دانشگاه آزاد اسلامی واحد تهران جنوب', 'score' => 12.5]]);
     $this->command->info('Edus seeded!');
     # Skill Seeder
     DB::table('skills')->delete();
     DB::table('skills')->insert([['user_id' => 1, 'title' => 'PHP', 'score' => 7.5, 'description' => 'در حد حرفه ای'], ['user_id' => 1, 'title' => 'CSS', 'score' => 9, 'description' => null], ['user_id' => 1, 'title' => 'HTML', 'score' => 6, 'description' => 'در حد متوسط ای'], ['user_id' => 1, 'title' => 'Ps', 'score' => 5.5, 'description' => null], ['user_id' => 1, 'title' => 'Ai', 'score' => 8.699999999999999, 'description' => 'در حد متوسط ای'], ['user_id' => 1, 'title' => 'MySQL', 'score' => 10, 'description' => 'در حد حرفه ای'], ['user_id' => 2, 'title' => 'PHP', 'score' => 9.5, 'description' => 'در حد حرفه ای'], ['user_id' => 2, 'title' => 'CSS', 'score' => 9.199999999999999, 'description' => null], ['user_id' => 2, 'title' => 'HTML', 'score' => 5.6, 'description' => 'در حد متوسط ای'], ['user_id' => 2, 'title' => 'Ps', 'score' => 4.5, 'description' => null], ['user_id' => 2, 'title' => 'Ai', 'score' => 6.7, 'description' => 'در حد متوسط ای'], ['user_id' => 2, 'title' => 'MySQL', 'score' => 10, 'description' => 'در حد حرفه ای']]);
     $this->command->info('Skills seeded!');
     # Comment Seeder
     DB::table('comments')->delete();
     DB::table('comments')->insert([['from_user_id' => 1, 'to_user_id' => 2, 'text' => 'این یک کامنت تست از طرف کاربر شماره 1 است.'], ['from_user_id' => 1, 'to_user_id' => 2, 'text' => 'مجددا یک کامنت تست از طرف کاربر شماره 1 است.'], ['from_user_id' => 2, 'to_user_id' => 1, 'text' => 'این کامنت تست از طرف کاربر شماره 2 هست.'], ['from_user_id' => 2, 'to_user_id' => 1, 'text' => 'مجددا یک کامنت تست از طرف کاربر شماره 2 است.']]);
     $this->command->info('Comments seeded!');
     # Rate Seeder
     DB::table('rates')->delete();
     DB::table('rates')->insert([['from_user_id' => 1, 'to_user_id' => 2, 'score' => 3.3], ['from_user_id' => 2, 'to_user_id' => 1, 'score' => 4.2]]);
     $this->command->info('Rates seeded!');
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('role_users')->delete();
     $userUser = Sentinel::findByCredentials(['login' => '*****@*****.**']);
     $adminUser = Sentinel::findByCredentials(['login' => '*****@*****.**']);
     $userRole = Sentinel::findRoleByName('Users');
     $adminRole = Sentinel::findRoleByName('Admins');
     // Assign the roles to the users
     $userRole->users()->attach($userUser);
     $adminRole->users()->attach($adminUser);
     $this->command->info('Users assigned to roles seeded!');
 }
 public function run()
 {
     try {
         $role = \Sentinel::findRoleByName('Administrator');
         $credentials = ['email' => '*****@*****.**', 'password' => 'password'];
         $user = \Sentinel::create($credentials);
         $role->users()->attach($user);
         $activation = \Activation::create($user);
         $activation_complete = \Activation::complete($user, $activation->code);
     } catch (\Exception $e) {
     }
 }
Beispiel #6
0
 /**
  * extending hieu-le/active function
  *
  * @param int $user_id
  *
  * @return bool
  */
 function is_admin($user_id = null)
 {
     if ($user_id) {
         $user = Sentinel::findById($user_id);
     } else {
         if (Sentinel::check()) {
             $user = Sentinel::getUser();
         } else {
             return false;
         }
     }
     $admin = Sentinel::findRoleByName('Administrator');
     return $user && $user->inRole($admin);
 }
 public function run()
 {
     try {
         $role = \Sentinel::getRoleRepository()->createModel()->create(['name' => 'Administrator', 'slug' => 'administrator']);
         $role = \Sentinel::findRoleByName('Administrator');
         $role->permissions = ['superadmin' => true, 'controlpanel' => true, 'admin.users.view' => true, 'admin.users.create' => true, 'admin.users.edit' => true, 'admin.users.destroy' => true, 'admin.roles.view' => true, 'admin.roles.create' => true, 'admin.roles.edit' => true, 'admin.roles.destroy' => true];
         $role->save();
         $credentials = ['email' => '*****@*****.**', 'password' => 'password'];
         $user = \Sentinel::create($credentials);
         $role->users()->attach($user);
         $activation = \Activation::create($user);
         $activation_complete = \Activation::complete($user, $activation->code);
     } catch (\Exception $e) {
     }
 }
 public function run()
 {
     try {
         $permissions = ['superadmin' => ['default' => true, 'description' => 'Super Admin', 'group_name' => 'admin::lang.permission.without_group'], 'controlpanel' => ['default' => true, 'description' => 'Access to the Control Panel', 'group_name' => 'admin::lang.permission.without_group'], 'admin.users.view' => ['default' => true, 'description' => 'View Users', 'group_name' => 'admin::lang.permission.without_group'], 'admin.users.create' => ['default' => true, 'description' => 'Create Users', 'group_name' => 'admin::lang.permission.without_group'], 'admin.users.edit' => ['default' => true, 'description' => 'Edit Users', 'group_name' => 'admin::lang.permission.without_group'], 'admin.users.destroy' => ['default' => true, 'description' => 'Delete Users', 'group_name' => 'admin::lang.permission.without_group'], 'admin.roles.view' => ['default' => true, 'description' => 'View Roles', 'group_name' => 'admin::lang.permission.without_group'], 'admin.roles.create' => ['default' => true, 'description' => 'Create Roles', 'group_name' => 'admin::lang.permission.without_group'], 'admin.roles.edit' => ['default' => true, 'description' => 'Edit Roles', 'group_name' => 'admin::lang.permission.without_group'], 'admin.roles.destroy' => ['default' => true, 'description' => 'Delete Roles', 'group_name' => 'admin::lang.permission.without_group'], 'admin.permissions.view' => ['default' => true, 'description' => 'View Permissions', 'group_name' => 'admin::lang.permission.without_group'], 'admin.permissions.create' => ['default' => true, 'description' => 'Create Permissions', 'group_name' => 'admin::lang.permission.without_group'], 'admin.permissions.edit' => ['default' => true, 'description' => 'Edit Permissions', 'group_name' => 'admin::lang.permission.without_group'], 'admin.permissions.destroy' => ['default' => true, 'description' => 'Delete Permissions', 'group_name' => 'admin::lang.permission.without_group']];
         //create records
         foreach ($permissions as $key => $permission) {
             PermissionModel::create(['value' => $key, 'description' => $permission['description'], 'group_name' => $permission['group_name']]);
         }
         $role = \Sentinel::findRoleByName('Administrator');
         //assign permissions to role
         foreach ($permissions as $key => $permission) {
             $role->addPermission($key, $permission['default']);
         }
         $role->save();
     } catch (\Exception $e) {
     }
 }
Beispiel #9
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     # User Seeder
     Sentinel::registerAndActivate(['email' => '*****@*****.**', 'password' => 'user123', 'first_name' => 'علی', 'last_name' => 'شفیعی', 'address1' => 'مجیدیه شمالی نرسیده به میدان سرباز کوچه شهید داوود علی بخشی پلاک 55 طبقه اول', 'address2' => 'سعادت آباد، کوی فراز شماره 86 بلوک 4 طبقه دوم واحد 4', 'address3' => 'سعدی جنوبی کوچه بانک تجارت پلاک 3 طبقه دوم']);
     Sentinel::registerAndActivate(['email' => '*****@*****.**', 'password' => 'admin123', 'first_name' => 'مجید', 'last_name' => 'نورعلی', 'address1' => 'مجیدیه شمالی نرسیده به میدان سرباز کوچه شهید داوود علی بخشی پلاک 55 طبقه اول', 'address2' => 'سعادت آباد، کوی فراز شماره 86 بلوک 4 طبقه دوم واحد 4', 'address3' => 'سعدی جنوبی کوچه بانک تجارت پلاک 3 طبقه دوم']);
     $this->command->info('Users seeded!');
     # Role Seeder
     DB::table('roles')->delete();
     Sentinel::getRoleRepository()->createModel()->create(['name' => 'users', 'slug' => 'users']);
     Sentinel::getRoleRepository()->createModel()->create(['name' => 'admins', 'slug' => 'admins']);
     $this->command->info('Roles seeded!');
     # User Role Seeder
     DB::table('role_users')->delete();
     $user = Sentinel::findByCredentials(['login' => '*****@*****.**']);
     $admin = Sentinel::findByCredentials(['login' => '*****@*****.**']);
     $userRole = Sentinel::findRoleByName('users');
     $adminRole = Sentinel::findRoleByName('admins');
     $userRole->users()->attach($user);
     $adminRole->users()->attach($admin);
     $this->command->info('Users assigned to roles seeded!');
     # Categories Table Seeder
     DB::table('cats')->delete();
     DB::table('cats')->insert([['title' => 'کاغذ'], ['title' => 'زینک'], ['title' => 'مرکب']]);
     $this->command->info('Categories Table Seeded.');
     # Orders Table Seeder
     DB::table('orders')->delete();
     DB::table('orders')->insert([['user_id' => '2', 'sum' => '208600', 'address' => 'سعدی جنوبی کوچه بانک تجارت پلاک 3 طبقه دوم', 'status' => '1'], ['user_id' => '2', 'sum' => '145500', 'address' => 'مجیدیه شمالی نرسیده به میدان سرباز کوچه شهید داوود علی بخشی پلاک 55 طبقه اول', 'status' => '0'], ['user_id' => '2', 'sum' => '650000', 'address' => 'سعدی جنوبی کوچه بانک تجارت پلاک 3 طبقه دوم', 'status' => '1']]);
     $this->command->info('Orders Table Seeded.');
     # Products Table Seeder
     DB::table('products')->delete();
     DB::table('products')->insert([['name' => 'کاغذ A4 Copymax', 'des' => 'کاغذ A4 Copymax کاغذ A4 Copymax کاغذ A4 Copymax', 'cat_id' => 1, 'size' => '210x297', 'weight' => 80, 'pic' => 'copimax.jpg', 'active' => 1], ['name' => 'کاغذ A4 DoubleA', 'des' => 'کاغذ A4 DoubleA کاغذ A4 DoubleA کاغذ A4 DoubleA', 'cat_id' => 1, 'size' => '210x297', 'weight' => 80, 'pic' => 'doublea.jpg', 'active' => 1], ['name' => 'زینک GTO', 'des' => 'زینک GTO زینک GTO زینک GTO', 'cat_id' => 2, 'size' => '326x256', 'weight' => 213, 'pic' => 'zinc1.jpg', 'active' => 1], ['name' => 'کاغذ JKcmax', 'des' => 'کاغذ JKcmax کاغذ JKcmax کاغذ JKcmax', 'cat_id' => 1, 'size' => '210x297', 'weight' => 80, 'pic' => 'jkcmax.jpg', 'active' => 1], ['name' => 'زینک دو ورقی', 'des' => 'زینک دو ورقی زینک دو ورقی زینک دو ورقی', 'cat_id' => 2, 'size' => '544x456', 'weight' => 253, 'pic' => 'zinc2.jpg', 'active' => 1], ['name' => 'زینگ دو و نیم ورقی اسپید', 'des' => 'زینگ دو و نیم ورقی اسپید زینگ دو و نیم ورقی اسپید زینگ دو و نیم ورقی اسپید', 'cat_id' => 2, 'size' => '700x500', 'weight' => 315, 'pic' => 'zinc3.jpg', 'active' => 1], ['name' => 'زینگ چهار و نیم ورقی', 'des' => 'زینگ چهار و نیم ورقی زینگ چهار و نیم ورقی زینگ چهار و نیم ورقی', 'cat_id' => 2, 'size' => '700x500', 'weight' => 315, 'pic' => 'zinc4.jpg', 'active' => 1], ['name' => 'مرکب Huaguang', 'des' => 'مرکب Huaguang مرکب Huaguang مرکب Huaguang', 'cat_id' => 3, 'size' => '454', 'weight' => 4545, 'pic' => 'uv1.jpg', 'active' => 1], ['name' => 'مرکب Huaguang 1', 'des' => 'مرکب Huaguang 1 مرکب Huaguang 1 مرکب Huaguang 1', 'cat_id' => 3, 'size' => '4564', 'weight' => 345, 'pic' => 'uv2.jpg', 'active' => 1], ['name' => 'مرکب چاپ', 'des' => 'مرکب چاپ مرکب چاپ مرکب چاپ', 'cat_id' => 3, 'size' => '4564', 'weight' => 345, 'pic' => 'uv3.jpg', 'active' => 1]]);
     $this->command->info('Products Seeded.');
     # Units Table Seeder
     DB::table('units')->delete();
     DB::table('units')->insert([['title' => 'بسته'], ['title' => 'کارتن'], ['title' => 'بند'], ['title' => 'گالن'], ['title' => 'جعبه'], ['title' => 'پالت']]);
     $this->command->info('Units Table Seeded.');
     # Unit Cats Table Seeder
     DB::table('unit_cats')->delete();
     DB::table('unit_cats')->insert([['cat_id' => '1', 'unit_id' => '1'], ['cat_id' => '1', 'unit_id' => '2'], ['cat_id' => '2', 'unit_id' => '1'], ['cat_id' => '3', 'unit_id' => '4'], ['cat_id' => '2', 'unit_id' => '6'], ['cat_id' => '3', 'unit_id' => '5']]);
     $this->command->info('Unit_Cats Table Seeded.');
     # Price Table Seeder
     DB::table('prices')->delete();
     DB::table('prices')->insert([['product_id' => '1', 'unit_id' => '1', 'price' => '100000'], ['product_id' => '1', 'unit_id' => '2', 'price' => '110000'], ['product_id' => '2', 'unit_id' => '1', 'price' => '200000'], ['product_id' => '2', 'unit_id' => '2', 'price' => '210000'], ['product_id' => '3', 'unit_id' => '1', 'price' => '300000'], ['product_id' => '3', 'unit_id' => '6', 'price' => '333000'], ['product_id' => '4', 'unit_id' => '1', 'price' => '400000'], ['product_id' => '4', 'unit_id' => '2', 'price' => '410000'], ['product_id' => '5', 'unit_id' => '1', 'price' => '500000'], ['product_id' => '5', 'unit_id' => '6', 'price' => '555000'], ['product_id' => '6', 'unit_id' => '1', 'price' => '600000'], ['product_id' => '6', 'unit_id' => '6', 'price' => '666000'], ['product_id' => '7', 'unit_id' => '1', 'price' => '700000'], ['product_id' => '7', 'unit_id' => '6', 'price' => '777000'], ['product_id' => '8', 'unit_id' => '4', 'price' => '800000'], ['product_id' => '8', 'unit_id' => '5', 'price' => '888000'], ['product_id' => '9', 'unit_id' => '4', 'price' => '900000'], ['product_id' => '9', 'unit_id' => '5', 'price' => '999000'], ['product_id' => '10', 'unit_id' => '4', 'price' => '910000'], ['product_id' => '10', 'unit_id' => '5', 'price' => '919000']]);
     $this->command->info('Prices Table Seeded.');
 }
Beispiel #10
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('roles')->delete();
     DB::table('users')->delete();
     DB::table('role_users')->delete();
     $roles = ['administradores' => ['name' => 'Administradores', 'slug' => 'administradores', 'permissions' => ['admin.system' => true]], 'invitados' => ['name' => 'Invitados', 'slug' => 'invitados']];
     foreach ($roles as $role) {
         Sentinel::getRoleRepository()->createModel()->fill($role)->save();
     }
     $this->command->info('Roles seeded!');
     $users = [['email' => '*****@*****.**', 'password' => '12345678', 'first_name' => 'Administrador', 'last_name' => 'Jenion', 'nickname' => 'admjenion'], ['email' => '*****@*****.**', 'password' => '12345678', 'first_name' => 'Invitado', 'last_name' => 'Jenion', 'nickname' => 'invjenion']];
     foreach ($users as $user) {
         Sentinel::registerAndActivate($user);
     }
     $this->command->info('Users seeded!');
     $admUser = Sentinel::findByCredentials(['login' => '*****@*****.**']);
     $invUser = Sentinel::findByCredentials(['login' => '*****@*****.**']);
     $invGroup = Sentinel::findRoleByName('Invitados');
     $admGroup = Sentinel::findRoleByName('Administradores');
     // Assign the groups to the users
     $invGroup->users()->attach($invUser);
     $admGroup->users()->attach($admUser);
     $this->command->info('Users assigned to role seeded!');
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $SYSTEM_ADMINISTRATOR = Sentinel::findRoleByName('System Administrator');
     $CONFERENCE_MANAGER = Sentinel::findRoleByName('Conference Manager');
     $EVENT_MANAGER = Sentinel::findRoleByName('Event Manager');
     $REGULAR_USER = Sentinel::findRoleByName('Regular User');
     // ---------------------------------------------------------------------
     // USER 1
     // ---------------------------------------------------------------------
     $user = ['username' => 'admin', 'email' => '*****@*****.**', 'password' => 'password1'];
     $user = Sentinel::registerAndActivate($user);
     $role = $SYSTEM_ADMINISTRATOR;
     $role->users()->attach($user);
     $user->permissions = $role->permissions;
     $user->save();
     $profile = ['is_owner' => true, 'email' => $user->email, 'phone' => '6041234567', 'first_name' => 'System', 'last_name' => 'Administrator', 'city' => 'Vancouver', 'country' => 'Canada', 'gender' => 'male'];
     $profile = new Profile($profile);
     $profile->user()->associate($user);
     $profile->save();
     // ---------------------------------------------------------------------
     // USER 2
     // ---------------------------------------------------------------------
     $user = ['username' => 'haniel', 'email' => '*****@*****.**', 'password' => 'password1'];
     $user = Sentinel::registerAndActivate($user);
     $role = $CONFERENCE_MANAGER;
     $role->users()->attach($user);
     $user->permissions = $role->permissions;
     $user->save();
     $profile = ['is_owner' => true, 'email' => $user->email, 'phone' => '6041234567', 'first_name' => 'Haniel', 'last_name' => 'Martino', 'city' => 'Vancouver', 'country' => 'Canada', 'gender' => 'male'];
     $profile = new Profile($profile);
     $profile->user()->associate($user);
     $profile->save();
     // ---------------------------------------------------------------------
     // UESR 3
     // ---------------------------------------------------------------------
     $user = ['username' => 'viggy', 'email' => '*****@*****.**', 'password' => 'password1'];
     $user = Sentinel::registerAndActivate($user);
     $role = $CONFERENCE_MANAGER;
     $role->users()->attach($user);
     $user->permissions = $role->permissions;
     $user->save();
     $profile = ['is_owner' => true, 'email' => $user->email, 'phone' => '6041234567', 'first_name' => 'Vincent', 'last_name' => 'Lore', 'city' => 'Vancouver', 'country' => 'Canada', 'birthdate' => '1993-02-08', 'gender' => 'male'];
     $profile = new Profile($profile);
     $profile->user()->associate($user);
     $profile->save();
     // ---------------------------------------------------------------------
     // USER 4
     // ---------------------------------------------------------------------
     $user = ['username' => 'gabby', 'email' => '*****@*****.**', 'password' => 'password1'];
     $user = Sentinel::registerAndActivate($user);
     $role = $CONFERENCE_MANAGER;
     $role->users()->attach($user);
     $user->permissions = $role->permissions;
     $user->save();
     $profile = ['is_owner' => true, 'email' => $user->email, 'phone' => '6041234567', 'first_name' => 'Gabriela', 'last_name' => 'Hernandez', 'city' => 'Vancouver', 'country' => 'Canada', 'birthdate' => '1993-02-16', 'gender' => 'female'];
     $profile = new Profile($profile);
     $profile->user()->associate($user);
     $profile->save();
     // ---------------------------------------------------------------------
     // USER 5
     // ---------------------------------------------------------------------
     $user = ['username' => 'james', 'email' => '*****@*****.**', 'password' => 'password1'];
     $user = Sentinel::registerAndActivate($user);
     $role = $CONFERENCE_MANAGER;
     $role->users()->attach($user);
     $user->permissions = $role->permissions;
     $user->save();
     $profile = ['is_owner' => true, 'email' => $user->email, 'phone' => '6041234567', 'first_name' => 'James', 'last_name' => 'Ma', 'city' => 'Vancouver', 'country' => 'Canada', 'birthdate' => '1992-01-23', 'gender' => 'male'];
     $profile = new Profile($profile);
     $profile->user()->associate($user);
     $profile->save();
     // ---------------------------------------------------------------------
     // USER 6
     // ---------------------------------------------------------------------
     $user = ['username' => 'martin', 'email' => '*****@*****.**', 'password' => 'password1'];
     $user = Sentinel::registerAndActivate($user);
     $role = $CONFERENCE_MANAGER;
     $role->users()->attach($user);
     $user->permissions = $role->permissions;
     $user->save();
     $profile = ['is_owner' => true, 'email' => $user->email, 'phone' => '6041234567', 'first_name' => 'Martin', 'last_name' => 'Tsang', 'city' => 'Vancouver', 'country' => 'Canada', 'birthdate' => '1993-05-15', 'gender' => 'male'];
     $profile = new Profile($profile);
     $profile->user()->associate($user);
     $profile->save();
     // ---------------------------------------------------------------------
     // USER 7
     // ---------------------------------------------------------------------
     $user = ['username' => 'chris', 'email' => '*****@*****.**', 'password' => 'password1'];
     $user = Sentinel::registerAndActivate($user);
     $role = $CONFERENCE_MANAGER;
     $role->users()->attach($user);
     $user->permissions = $role->permissions;
     $user->save();
     $user->permissions = $role->permissions;
     $user->save();
     $profile = ['is_owner' => true, 'email' => $user->email, 'phone' => '6041234567', 'first_name' => 'Christopher', 'last_name' => 'Yang', 'city' => 'Vancouver', 'country' => 'Canada', 'birthdate' => '1993-08-21', 'gender' => 'male'];
     $profile = new Profile($profile);
     $profile->user()->associate($user);
     $profile->save();
     // ---------------------------------------------------------------------
     // USER 8
     // ---------------------------------------------------------------------
     $user = ['username' => 'john', 'email' => '*****@*****.**', 'password' => 'password1'];
     $user = Sentinel::registerAndActivate($user);
     $role = $REGULAR_USER;
     $role->users()->attach($user);
     $user->permissions = $role->permissions;
     $user->save();
     $profile = ['is_owner' => true, 'email' => $user->email, 'phone' => '6041234567', 'first_name' => 'John', 'last_name' => 'Smith', 'city' => 'Vancouver', 'country' => 'Canada', 'birthdate' => '1980-01-01', 'gender' => 'male'];
     $profile = new Profile($profile);
     $profile->user()->associate($user);
     $profile->save();
     $profile = ['first_name' => 'Mary', 'last_name' => 'Smith', 'city' => 'Vancouver', 'country' => 'Canada', 'birthdate' => '1980-01-01', 'gender' => 'female'];
     $profile = new Profile($profile);
     $profile->user()->associate($user);
     $profile->save();
     $profile = ['first_name' => 'Alice', 'last_name' => 'Smith', 'city' => 'Vancouver', 'country' => 'Canada', 'birthdate' => '2006-01-01', 'gender' => 'female'];
     $profile = new Profile($profile);
     $profile->user()->associate($user);
     $profile->save();
 }
 protected function createAdminUserAndRole()
 {
     $permissions = ['superadmin' => ['default' => true, 'description' => 'Super Admin'], 'controlpanel' => ['default' => true, 'description' => 'Access to the Control Panel'], 'admin.users.view' => ['default' => true, 'description' => 'View Users'], 'admin.users.create' => ['default' => true, 'description' => 'Create Users'], 'admin.users.edit' => ['default' => true, 'description' => 'Edit Users'], 'admin.users.destroy' => ['default' => true, 'description' => 'Delete Users'], 'admin.roles.view' => ['default' => true, 'description' => 'View Roles'], 'admin.roles.create' => ['default' => true, 'description' => 'Create Roles'], 'admin.roles.edit' => ['default' => true, 'description' => 'Edit Roles'], 'admin.roles.destroy' => ['default' => true, 'description' => 'Delete Roles'], 'admin.permissions.view' => ['default' => true, 'description' => 'View Permissions'], 'admin.permissions.create' => ['default' => true, 'description' => 'Create Permissions'], 'admin.permissions.edit' => ['default' => true, 'description' => 'Edit Permissions'], 'admin.permissions.destroy' => ['default' => true, 'description' => 'Delete Permissions']];
     try {
         //create admin user
         $credentials = ['email' => '*****@*****.**', 'password' => 'password'];
         $user = \Sentinel::create($credentials);
         $activation = \Activation::create($user);
         $activation_complete = \Activation::complete($user, $activation->code);
         //create admin role
         $role = \Sentinel::getRoleRepository()->createModel()->create(['name' => 'Administrator', 'slug' => 'administrator']);
         $role = \Sentinel::findRoleByName('Administrator');
         //add permissions to role
         foreach ($permissions as $key => $permission) {
             $role->addPermission($key, $permission['default']);
         }
         $role->save();
         //attach admin user to admin role
         $role->users()->attach($user);
         $this->info('Admin Role and User created successfully.');
         $this->addPermissions($permissions);
     } catch (\Exception $e) {
         $this->info('Something went wrong while creating Admin Role and User.');
         $this->error($e);
     }
 }
 protected function createAdminUserAndRole()
 {
     try {
         $role = \Sentinel::getRoleRepository()->createModel()->create(['name' => 'Administrator', 'slug' => 'administrator']);
         $role = \Sentinel::findRoleByName('Administrator');
         $role->permissions = ['superadmin' => true, 'controlpanel' => true, 'admin.users.view' => true, 'admin.users.create' => true, 'admin.users.edit' => true, 'admin.users.destroy' => true, 'admin.roles.view' => true, 'admin.roles.create' => true, 'admin.roles.edit' => true, 'admin.roles.destroy' => true];
         $role->save();
         $credentials = ['email' => '*****@*****.**', 'password' => 'password'];
         $user = \Sentinel::create($credentials);
         $role->users()->attach($user);
         $activation = \Activation::create($user);
         $activation_complete = \Activation::complete($user, $activation->code);
         $this->info('Admin Role and User created successfully.');
     } catch (\Exception $e) {
         $this->info('Something went wrong while creating Admin Role and User.');
     }
 }
Beispiel #14
0
 public function run()
 {
     $_user = Sentinel::register(['email' => '*****@*****.**', 'password' => 'abc123'], true);
     $group = Sentinel::findRoleByName('Admin');
     $group->users()->attach($_user);
 }