Ejemplo n.º 1
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::statement("SET foreign_key_checks = 0");
     \CodeProject\Entities\User::truncate();
     \CodeProject\Entities\User::create(['name' => 'Michel', 'email' => '*****@*****.**', 'password' => bcrypt(123456), 'remember_token' => str_random(10)]);
     factory(\CodeProject\Entities\User::class, 9)->create();
 }
Ejemplo n.º 2
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     //
     \CodeProject\Entities\User::truncate();
     factory(\CodeProject\Entities\User::class)->create(['name' => "Marco Aurélio", 'email' => "*****@*****.**", 'password' => bcrypt(123456), 'remember_token' => str_random(10)]);
     factory(CodeProject\Entities\User::class, 10)->create();
 }
Ejemplo n.º 3
0
 public function removeMember(array $data)
 {
     try {
         $project = $this->repositoy->skipPresenter()->find($data['id']);
         $user = $this->user->find($data['$memberId']);
         $project->members()->detach($user);
     } catch (\Exception $e) {
         return ['error' => true, 'message' => $e->getMessage()];
     }
 }
 public function delete($id)
 {
     $entity = User::find($id);
     if (is_null($entity)) {
         return Errors::invalidId($id);
     }
     if (count($entity->memberOf) > 0) {
         return Errors::basic("Este usuário participa de projetos. Exclusão cancelada.");
     }
     $this->repository->delete($id);
     return ['message' => "Registro deletado!"];
 }
Ejemplo n.º 5
0
 public function verify($username, $password)
 {
     $credentials = ['email' => $username, 'password' => $password];
     if (Auth::once($credentials)) {
         return Auth::user()->id;
     }
     if (Auth::validate(['email' => $username, 'password' => $password])) {
         $user = \CodeProject\Entities\User::where('email', $username)->first();
         return $user->id;
     }
     return false;
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('project_members')->delete();
     for ($i = 1;; $i++) {
         if ($i > 50) {
             break;
         }
         for (;;) {
             $projectId = \CodeProject\Entities\Project::all()->lists('id')->random(1);
             $userId = \CodeProject\Entities\User::all()->lists('id')->random(1);
             if (\CodeProject\Entities\ProjectMember::where('project_id', $projectId)->where('member_id', $userId)->count() == 0) {
                 \CodeProject\Entities\ProjectMember::create(['project_id' => $projectId, 'member_id' => $userId]);
                 break;
             }
         }
     }
 }
Ejemplo n.º 7
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     /*factory('CodeProject\Entities\User')->create(
           [
               'name' => 'Bruno',
               'email' => '*****@*****.**',
               'password' => bcrypt(123456),
               'remember_token' => str_random(10)
           ]
       );*/
     DB::statement('SET foreign_key_checks = 0');
     \CodeProject\Entities\User::truncate();
     factory(\CodeProject\Entities\User::class)->create();
     // $this->call(UserTableSeeder::class);
     $this->call(ClientTableSeeder::class);
     $this->call(ProjectTableSeeder::class);
     DB::statement('SET foreign_key_checks = 1');
     Model::reguard();
 }
Ejemplo n.º 8
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Eloquent::unguard();
     /*Desativa chave etrangeira*/
     DB::statement('SET FOREIGN_KEY_CHECKS=0;');
     \CodeProject\Entities\ProjectTask::truncate();
     \CodeProject\Entities\ProjectMember::truncate();
     \CodeProject\Entities\ProjectNote::truncate();
     \CodeProject\Entities\Project::truncate();
     \CodeProject\Entities\Client::truncate();
     \CodeProject\Entities\User::truncate();
     $this->call(UserTableSeeder::class);
     $this->call(ClientTableSeeder::class);
     $this->call(ProjectTableSeeder::class);
     $this->call(ProjectNoteTableSeeder::class);
     $this->call(ProjectMembersTableSeeder::class);
     $this->call(ProjectTasksTableSeeder::class);
     /*ativa chave estrangeira*/
     DB::statement('SET FOREIGN_KEY_CHECKS=1;');
 }
Ejemplo n.º 9
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     DB::statement('SET FOREIGN_KEY_CHECKS=0;');
     Project::truncate();
     User::truncate();
     Client::truncate();
     ProjectNote::truncate();
     ProjectTask::truncate();
     ProjectMember::truncate();
     OauthClient::truncate();
     DB::statement('SET FOREIGN_KEY_CHECKS=1;');
     $this->call(ClientTableSeeder::class);
     $this->call(UserTableSeeder::class);
     $this->call(ProjectTableSeeder::class);
     $this->call(ProjectNoteTableSeeder::class);
     $this->call(ProjectTaskTableSeeder::class);
     $this->call(ProjectMemberTableSeeder::class);
     $this->call(OauthClientSeeder::class);
     Model::reguard();
 }
Ejemplo n.º 10
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     DB::statement('SET foreign_key_checks = 0');
     ProjectNote::truncate();
     ProjectTask::truncate();
     ProjectMember::truncate();
     ProjectFile::truncate();
     Project::truncate();
     Client::truncate();
     User::truncate();
     OAuthClient::truncate();
     DB::statement('SET foreign_key_checks = 1');
     $this->call(UserTableSeeder::class);
     $this->call(ClientTableSeeder::class);
     $this->call(ProjectTableSeeder::class);
     $this->call(ProjectNoteTableSeeder::class);
     $this->call(ProjectMemberTableSeeder::class);
     $this->call(ProjectTaskTableSeeder::class);
     $this->call(OAuthClientTableSeeder::class);
     Model::reguard();
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     User::truncate();
     factory(User::class)->create(['name' => 'Felipe Minello', 'email' => '*****@*****.**', 'password' => bcrypt(123456), 'remember_token' => str_random(10)]);
     factory(User::class, 10)->create();
 }
Ejemplo n.º 12
0
 public function removeMember($project_id, $member_id)
 {
     $project = Project::find($project_id);
     if (is_null($project)) {
         return Errors::invalidId($project_id);
     }
     if (is_null(User::find($member_id))) {
         return Errors::invalidId($member_id);
     }
     if ($member_id == $project->owner_id) {
         return Errors::basic("Não é possível remover o dono do projeto.");
     }
     $pm = $this->repository->findMemberAssociation($project_id, $member_id);
     if (is_null($pm)) {
         return Errors::basic("Este usuário não é membro do projeto.");
     }
     return $this->projectMemberService->delete($pm->id);
 }
Ejemplo n.º 13
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.
|
*/
$factory->define(CodeProject\Entities\User::class, function (Faker\Generator $faker) {
    return ['name' => $faker->name, 'email' => strtolower($faker->email), 'password' => bcrypt('123456'), 'remember_token' => str_random(10)];
});
$factory->define(CodeProject\Entities\Client::class, function (Faker\Generator $faker) {
    return ['name' => $faker->name, 'responsible' => $faker->name, 'email' => strtolower($faker->email), 'phone' => $faker->phoneNumber, 'address' => $faker->address, 'obs' => $faker->sentence];
});
$factory->define(CodeProject\Entities\Project::class, function (Faker\Generator $faker) {
    return ['owner_id' => \CodeProject\Entities\User::all()->lists('id')->random(1), 'client_id' => \CodeProject\Entities\Client::all()->lists('id')->random(1), 'name' => $faker->sentence, 'description' => $faker->text(400), 'progress' => $faker->numberBetween(0, 100), 'status' => $faker->numberBetween(0, 2), 'due_date' => $faker->dateTimeAD($min = 'now')];
});
$factory->define(CodeProject\Entities\ProjectNote::class, function (Faker\Generator $faker) {
    return ['project_id' => \CodeProject\Entities\Project::all()->lists('id')->random(1), 'title' => $faker->sentence, 'note' => $faker->text(400)];
});
$factory->define(CodeProject\Entities\ProjectTask::class, function (Faker\Generator $faker) {
    return ['project_id' => \CodeProject\Entities\Project::all()->lists('id')->random(1), 'name' => $faker->sentence, 'start_date' => $faker->dateTimeAD($max = 'now'), 'due_date' => $faker->dateTimeAD($min = 'now'), 'status' => $faker->numberBetween(0, 2)];
});
 public function userProjects($userId)
 {
     $user = User::find($userId);
     return $user->projects;
 }
    }
    return ['owner_id' => $faker->randomElement($o), 'client_id' => $faker->randomElement($c), 'name' => $faker->word, 'description' => $faker->sentence, 'progress' => rand(1, 100), 'status' => rand(1, 3), 'due_date' => $faker->dateTime('now')];
});
$factory->define(ProjectNote::class, function (Generator $faker) {
    $project = Project::all()->lists('id');
    foreach ($project as $value) {
        $p[] = $value;
    }
    return ['project_id' => $faker->randomElement($p), 'title' => $faker->title, 'note' => $faker->paragraph];
});
$factory->define(ProjectTask::class, function (Generator $faker) {
    $project = Project::all()->lists('id');
    foreach ($project as $value) {
        $p[] = $value;
    }
    return ['project_id' => $faker->randomElement($p), 'name' => $faker->word, 'start_date' => $faker->dateTime('now'), 'due_date' => $faker->dateTime('now'), 'status' => rand(1, 3)];
});
$factory->define(ProjectMembers::class, function (Generator $faker) {
    $project = Project::all()->lists('id');
    foreach ($project as $value) {
        $p[] = $value;
    }
    $user = User::all()->lists('id');
    foreach ($user as $value) {
        $u[] = $value;
    }
    return ['project_id' => $faker->randomElement($p), 'user_id' => $faker->randomElement($u)];
});
$factory->define(OauthClients::class, function (Generator $faker) {
    return ['id' => $faker->md5, 'secret' => $faker->text(10), 'name' => $faker->name];
});
Ejemplo n.º 16
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     User::truncate();
     factory(User::class)->create(['name' => 'Marinho Piacentinis', 'email' => '*****@*****.**', 'password' => bcrypt(12345), 'remember_token' => str_random(10)]);
     factory(User::class, 10)->create();
 }
Ejemplo n.º 17
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.
|
*/
$factory->define(CodeProject\Entities\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(CodeProject\Entities\Client::class, function (Faker\Generator $faker) {
    return ['name' => $faker->name, 'responsible' => $faker->name, 'email' => $faker->email, 'phone' => $faker->phoneNumber, 'address' => $faker->address, 'obs' => $faker->sentence];
});
$factory->define(CodeProject\Entities\Project::class, function (Faker\Generator $faker) {
    return ['owner_id' => \CodeProject\Entities\User::all()->lists('id')->random(1), 'client_id' => \CodeProject\Entities\Client::all()->lists('id')->random(1), 'name' => $faker->name, 'description' => $faker->sentence, 'progress' => $faker->NumberBetween(0, 100), 'status' => $faker->numberBetween(1, 3), 'due_date' => $faker->dateTime];
});
$factory->define(CodeProject\Entities\ProjectNote::class, function (Faker\Generator $faker) {
    return ['project_id' => \CodeProject\Entities\Project::all()->lists('id')->random(1), 'title' => $faker->word, 'note' => $faker->paragraph];
});
$factory->define(CodeProject\Entities\ProjectTask::class, function (Faker\Generator $faker) {
    return ['project_id' => \CodeProject\Entities\Project::all()->lists('id')->random(1), 'name' => $faker->word, 'start_date' => $faker->dateTime, 'due_date' => $faker->dateTime, 'status' => $faker->numberBetween(1, 2)];
});
$factory->define(CodeProject\Entities\ProjectMember::class, function (Faker\Generator $faker) {
    return ['project_id' => \CodeProject\Entities\Project::all()->lists('id')->random(1), 'user_id' => \CodeProject\Entities\User::all()->lists('id')->random(1)];
});
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     User::truncate();
     factory(User::class, 10)->create();
 }
Ejemplo n.º 19
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     \CodeProject\Entities\User::truncate();
     factory(\CodeProject\Entities\User::class)->create(['name' => 'jayson', 'email' => '*****@*****.**', 'password' => bcrypt(123456)]);
     factory(\CodeProject\Entities\User::class, 10)->create();
 }
Ejemplo n.º 20
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     User::truncate();
     factory(User::class)->create(['name' => 'lucas', 'email' => '*****@*****.**', 'password' => bcrypt(123456), 'remember_token' => str_random(10)]);
     factory(User::class, 10)->create();
 }
Ejemplo n.º 21
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     User::truncate();
     factory(\CodeProject\Entities\User::class)->create(['name' => 'Bruno', 'email' => '*****@*****.**', 'password' => bcrypt(123456), 'remember_token' => str_random(10)]);
     factory(User::class, 10)->create();
 }
Ejemplo n.º 22
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     \CodeProject\Entities\User::truncate();
     factory(\CodeProject\Entities\User::class, 10)->create();
 }
 /**
  * Create a new user instance after a valid registration.
  *
  * @param  array  $data
  * @return User
  */
 protected function create(array $data)
 {
     return User::create(['name' => $data['name'], 'email' => $data['email'], 'password' => bcrypt($data['password'])]);
 }
Ejemplo n.º 24
0
 public function removeMember($id, $memberId)
 {
     $this->checkProjectPermissions($id);
     try {
         $project = $this->repository->find($id);
         $user = User::find($memberId);
         $project->member()->detach($user);
         return ['message' => 'Usuário removido do projeto com sucesso'];
     } catch (\Exception $e) {
         throw new ServiceException("Usuários do projeto não localizados");
     }
 }
Ejemplo n.º 25
0
 public function authenticated()
 {
     $idUser = Authorizer::getResourceOwnerId();
     return $this->user->find($idUser);
 }
Ejemplo n.º 26
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     \CodeProject\Entities\User::truncate();
     factory(\CodeProject\Entities\User::class)->create(['name' => 'Paulo', 'email' => '*****@*****.**', 'password' => bcrypt(123), 'remember_token' => str_random(10)]);
     factory(\CodeProject\Entities\User::class, 10)->create();
 }
Ejemplo n.º 27
0
|
*/
$factory->define(CodeProject\Entities\User::class, function (Faker\Generator $faker) {
    /*
    return [
        'name' => $faker->name,
        'email' => $faker->email,
        'password' => bcrypt(str_random(10)),
        'remember_token' => str_random(10),
    ];
    */
    return ['name' => 'Renato', 'email' => '*****@*****.**', 'password' => bcrypt(12345), 'remember_token' => str_random(10)];
});
$factory->define(CodeProject\Entities\Client::class, function (Faker\Generator $faker) {
    return ['name' => $faker->name, 'responsible' => $faker->name, 'email' => $faker->email, 'phone' => $faker->phoneNumber, 'address' => $faker->address, 'obs' => $faker->sentence()];
});
$factory->define(CodeProject\Entities\Project::class, function (Faker\Generator $faker) {
    return ['owner_id' => \CodeProject\Entities\User::orderByRaw("RAND()")->first()->getKey(), 'client_id' => \CodeProject\Entities\Client::orderByRaw("RAND()")->first()->getKey(), 'name' => $faker->name, 'description' => $faker->sentence(), 'progress' => $faker->randomDigitNotNull, 'status' => $faker->randomDigitNotNull, 'due_date' => $faker->dateTime];
});
$factory->define(CodeProject\Entities\ProjectNote::class, function (Faker\Generator $faker) {
    return ['project_id' => \CodeProject\Entities\Project::orderByRaw("RAND()")->first()->getKey(), 'title' => $faker->word, 'note' => $faker->paragraph];
});
$factory->define(CodeProject\Entities\ProjectTask::class, function (Faker\Generator $faker) {
    return ['project_id' => \CodeProject\Entities\Project::orderByRaw("RAND()")->first()->getKey(), 'name' => $faker->name, 'status' => $faker->randomDigitNotNull, 'start_date' => $faker->dateTime, 'due_date' => $faker->dateTime];
});
$factory->define(CodeProject\Entities\ProjectMember::class, function (Faker\Generator $faker) {
    return ['project_id' => \CodeProject\Entities\Project::orderByRaw("RAND()")->first()->getKey(), 'user_id' => \CodeProject\Entities\User::orderByRaw("RAND()")->first()->getKey()];
});
$factory->define(CodeProject\Entities\OAuth2::class, function (Faker\Generator $faker) {
    return ['id' => md5(rand(10000, 999999)), 'name' => md5(rand(10000, 999999)), 'secret' => md5(rand(10000, 999999))];
});