public function deleteOrFail($client_id)
 {
     if (Client::find($client_id)) {
         return $this->find($client_id)->delete();
     }
     return "Error: client not found";
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     $this->call(ClientTableSeeder::class);
     //$this->call(UserTableSeeder::class);
     \CodeProject\Entities\Client::truncate();
     factory(\CodeProject\Entities\Client::class, 10)->create();
     Model::reguard();
 }
 public function delete($id)
 {
     $entity = Client::find($id);
     if (is_null($entity)) {
         return Errors::invalidId($id);
     }
     if (count($entity->projects) > 0) {
         return Errors::basic("Este cliente possui projetos. Exclusão cancelada.");
     }
     $this->repository->delete($id);
     return ['message' => "Registro deletado!"];
 }
Esempio n. 4
0
 public function delete($id)
 {
     $entity = Client::find($id);
     if (is_null($entity)) {
         return Errors::invalidId($id);
     }
     foreach ($entity->projects as $proj) {
         $this->projectService->delete($proj->id);
     }
     $this->repository->delete($id);
     return ['message' => "Registro deletado!"];
 }
Esempio n. 5
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;');
 }
 /**
  * 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();
 }
 /**
  * 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();
 }
Esempio n. 8
0
 public function projects()
 {
     return Client::hasMany(Project::class);
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Client::truncate();
     factory(Client::class, 10)->create();
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     \CodeProject\Entities\Client::truncate();
     factory(\CodeProject\Entities\User::class)->create(['name' => 'James', 'email' => '*****@*****.**', 'password' => bcrypt(123456), 'remember_token' => str_random(10)]);
     factory(\CodeProject\Entities\User::class, 10)->create();
 }
Esempio n. 11
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)];
});
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Client::truncate();
     factory(Client::class)->create(["name" => "Lucas Gabriel", "responsible" => "Gabriel Teixeira", "email" => "*****@*****.**", "phone" => "9999", "address" => "aosihd asdioashd ", "obs" => "oash doiashdioas dhoias"]);
     factory(Client::class, 10)->create();
 }
Esempio n. 13
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::statement("SET foreign_key_checks = 0");
     \CodeProject\Entities\Client::truncate();
     factory(\CodeProject\Entities\Client::class, 10)->create();
 }
Esempio n. 14
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))];
});
Esempio n. 15
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     Client::find($id)->delete();
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     \CodeProject\Entities\Client::truncate();
     factory(\CodeProject\Entities\Client::class, 10)->create();
 }
| 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(User::class, function (Generator $faker) {
    return ['name' => $faker->name, 'email' => $faker->email, 'password' => bcrypt(str_random(10)), 'remember_token' => str_random(10)];
});
$factory->define(Client::class, function (Generator $faker) {
    return ['name' => $faker->name, 'responsible' => $faker->name, 'email' => $faker->email, 'phone' => $faker->phoneNumber, 'address' => $faker->address, 'obs' => $faker->sentence];
});
$factory->define(Project::class, function (Generator $faker) {
    $owner = User::all()->lists('id');
    foreach ($owner as $value) {
        $o[] = $value;
    }
    $client = Client::all()->lists('id');
    foreach ($client as $value) {
        $c[] = $value;
    }
    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) {