示例#1
0
文件: Role.php 项目: SocietyCMS/User
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('user__roles')->delete();
     $admin = DB::table('user__roles')->insertGetId(['name' => 'admin', 'display_name' => 'Site Administrator', 'description' => 'User is allowed to manage the full site', 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     $user = EloquentUser::where('email', '=', '*****@*****.**')->first();
     $user->roles()->attach($admin);
     DB::table('user__roles')->insert(['name' => 'owner', 'display_name' => 'Project Owner', 'description' => 'User is the owner of a given project', 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
 }
示例#2
0
 /**
  * Create a new user instance after a valid registration.
  *
  * @param  array  $data
  * @return User
  */
 protected function create(array $data)
 {
     return EloquentUser::create(['first_name' => $data['first_name'], 'last_name' => $data['last_name'], 'email' => $data['email'], 'password' => bcrypt($data['password'])]);
 }
示例#3
0
 public function transform(EloquentUser $user)
 {
     return ['id' => (int) $user->id, 'email' => $user->email, 'first_name' => $user->first_name, 'last_name' => $user->last_name, 'last_login' => $user->last_login, 'created_at' => $user->created_at, 'updated_at' => $user->updated_at, 'present' => ['fullname' => $user->present()->fullname, 'createdAt' => $user->present()->createdAt, 'updatedAt' => $user->present()->updatedAt, 'lastLogin' => $user->present()->lastLogin]];
 }
示例#4
0
<?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.
|
*/
use Illuminate\Support\Str;
$factory->define(\Modules\Page\Entities\Page::class, function (Faker\Generator $faker) {
    return ['title' => $title = ucfirst($faker->words(1, true)), 'slug' => Str::slug("{$title} {$faker->randomDigitNotNull}"), 'body' => $faker->paragraphs($faker->numberBetween(8, 30), true), 'published' => $faker->boolean(80), 'user_id' => $faker->randomElement(\Modules\User\Entities\Entrust\EloquentUser::all()->lists('id')->toArray()), 'created_at' => $start = $faker->dateTimeThisYear, 'updated_at' => $faker->dateTimeBetween($start)];
});