Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,26 @@ Esta é a API do aplicativo Cronos-Develop.
### Referências:
### Recomendações de Estudo:
## Documentação:
### Como criar banco de dados e popular:

Uma vez que a conexão com o banco de dados estiver configurada, o primeiro comando a ser utilizado é:

```
php artisan migrate
```
Isso irá checar se as tabelas no banco de dados estão criadas, e se não estiverem, são automaticamente feitas de acordo com as migrates.
As migrates podem ser vistas em database/migrations/.

Depois disso, basta utilizar o seguinte comando:

```
php artisan db:seed
```
Isso ira popular o banco de dados de acordo com as factories em database/factories.

Nota:
Utilize `php artisan migrate --seed` para fazer os dois comandos ao mesmo tempo

## Deploy:

# Instruções de Execução em Máquina Local:
Expand Down
10 changes: 10 additions & 0 deletions app/Http/Controllers/EmpresaController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class EmpresaController extends Controller
{
//
}
10 changes: 10 additions & 0 deletions app/Http/Controllers/PerguntaController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class PerguntaController extends Controller
{
//
}
10 changes: 10 additions & 0 deletions app/Http/Controllers/UsuarioController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class UsuarioController extends Controller
{
//
}
16 changes: 16 additions & 0 deletions app/Models/Empresa.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class Empresa extends Model
{
use HasFactory;

public function usuarios() : BelongsTo {
return $this->belongsTo(Usuario::class);
}
}
11 changes: 11 additions & 0 deletions app/Models/Pergunta.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Pergunta extends Model
{
use HasFactory;
}
47 changes: 0 additions & 47 deletions app/Models/User.php

This file was deleted.

20 changes: 20 additions & 0 deletions app/Models/Usuario.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;

class Usuario extends Model
{
use HasFactory;

public function empresas() : HasMany {
return $this->hasMany(Empresa::class);
}

public function FunctionName() : Returntype {

}
}
30 changes: 30 additions & 0 deletions database/factories/EmpresaFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace Database\Factories;

use App\Models\Empresa;
use App\Models\Usuario;
use Illuminate\Database\Eloquent\Factories\Factory;

/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Empresa>
*/
class EmpresaFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
$usr_id = Usuario::all()->random()->id;
return [
'usuario_id' => $usr_id,
'usuario_parceiro_id' => Usuario::all()->except($usr_id)->random()->id,
'nome_da_empresa' => $this->faker->company(),
'nicho' => $this->faker->jobTitle(),
'resumo' => $this->faker->realText($maxNbChars = 200, $indexSize = 2)
];
}
}
23 changes: 23 additions & 0 deletions database/factories/PerguntaFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace Database\Factories;

use Illuminate\Database\Eloquent\Factories\Factory;

/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Pergunta>
*/
class PerguntaFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
//
];
}
}
44 changes: 0 additions & 44 deletions database/factories/UserFactory.php

This file was deleted.

36 changes: 36 additions & 0 deletions database/factories/UsuarioFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

namespace Database\Factories;

use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Facades\Hash;

/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Usuario>
*/
class UsuarioFactory extends Factory
{
protected static ?string $password;
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
$faker = fake('pt_BR');
$empresario = $faker->boolean();
return [
'name' => $faker->name(),
'email' => $faker->unique()->safeEmail(),
'telefone' => $faker->phoneNumber(),
'senha' => static::$password ??= Hash::make('password'),
'endereco' => $faker->address(),
'cep' => $faker->numerify('######-###'),
'nascimento' => $faker->date(),
'empresario' => $empresario,
'cpf_cnpj' => $empresario ? $faker->cnpj() : $faker->cpf(),
'nome_da_empresa' => $empresario ? $faker->company() : NULL
];
}
}
49 changes: 0 additions & 49 deletions database/migrations/0001_01_01_000000_create_users_table.php

This file was deleted.

38 changes: 38 additions & 0 deletions database/migrations/2024_04_22_022707_create_usuarios_table.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('usuarios', function (Blueprint $table) {
$table->id();
// $table->primary("id");
$table->string('name');
$table->string('email')->unique();
$table->string('telefone');
$table->string('senha');
$table->string('endereco');
$table->string('cep');
$table->date('nascimento');
$table->boolean('empresario');
$table->string('cpf_cnpj');
$table->string('nome_da_empresa')->nullable();
$table->timestamps();
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('usuarios');
}
};
Loading