diff --git a/.env.example b/.env.example index e478abb..22e3741 100644 --- a/.env.example +++ b/.env.example @@ -44,3 +44,7 @@ PUSHER_APP_CLUSTER=mt1 MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}" MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" + +WEB_CLIENT_EMAIL=informaticamps@buzon.uy +WEB_CLIENT_NAME=web +WEB_CLIENT_PASS=pass \ No newline at end of file diff --git a/README.md b/README.md index 9b5cd81..11d1de2 100644 --- a/README.md +++ b/README.md @@ -44,12 +44,15 @@ docker-compose exec app composer update docker-compose exec app php artisan key:generate ``` -6. Corré las migraciones de Laravel +6. Corré las migraciones y seeders de Laravel ```bash -docker-compose exec app php artisan migrate +docker-compose exec app php artisan migrate --seed ``` +7. Copia el token que se imprime al correr los seeders. Lo necesitamos para autenticar las llamadas que hagamos desde nuestro cliente web + + Ahora la aplicación está corriendo y la podés ver en el puerto 8000 de tu dominio o IP. En caso de que estés en tu máquina local, la vas a ver accediendo a `http://localhost:8000` desde tu navegador. Podés usar el comando `logs` para ver los logs generados por tus servicios: diff --git a/app/GrupoDeCompra.php b/app/GrupoDeCompra.php index 5b5475e..91de6c6 100644 --- a/app/GrupoDeCompra.php +++ b/app/GrupoDeCompra.php @@ -9,5 +9,11 @@ class GrupoDeCompra extends Model public $timestamps = false; protected $fillable = [ "nombre","region","telefono","correo","referente_finanzas","cantidad_de_nucleos"]; protected $table = 'grupos_de_compra'; + public static $regiones = [ + 'NORTE', + 'SUR', + 'ESTE', + 'OESTE' + ]; } diff --git a/database/migrations/2014_10_12_000000_create_users_table.php b/database/migrations/2014_10_12_000000_create_users_table.php index 621a24e..c8ca86e 100644 --- a/database/migrations/2014_10_12_000000_create_users_table.php +++ b/database/migrations/2014_10_12_000000_create_users_table.php @@ -20,6 +20,7 @@ class CreateUsersTable extends Migration $table->timestamp('email_verified_at')->nullable(); $table->string('password'); $table->rememberToken(); + $table->string('api_token',60); $table->timestamps(); }); } diff --git a/database/seeds/DatabaseSeeder.php b/database/seeds/DatabaseSeeder.php index 237dfc5..cceafbf 100644 --- a/database/seeds/DatabaseSeeder.php +++ b/database/seeds/DatabaseSeeder.php @@ -11,6 +11,6 @@ class DatabaseSeeder extends Seeder */ public function run() { - // $this->call(UserSeeder::class); + $this->call(UserSeeder::class); } } diff --git a/database/seeds/UserSeeder.php b/database/seeds/UserSeeder.php new file mode 100644 index 0000000..561280d --- /dev/null +++ b/database/seeds/UserSeeder.php @@ -0,0 +1,27 @@ +insert([ + 'name' => $web_client_name, + 'email' => env('WEB_CLIENT_EMAIL', 'informaticamps@buzon.uy'), + 'password' => Hash::make(env('WEB_CLIENT_PASS', 'pass')), + 'api_token' => $api_token + ]); + dump('Api token for ' . $web_client_name . ' is: ' . $api_token); + + $api_token = Str::random(60); + } +} diff --git a/routes/api.php b/routes/api.php index bcb8b18..6f9464b 100644 --- a/routes/api.php +++ b/routes/api.php @@ -2,6 +2,7 @@ use Illuminate\Http\Request; use Illuminate\Support\Facades\Route; +use App\GrupoDeCompra; /* |-------------------------------------------------------------------------- @@ -14,6 +15,8 @@ use Illuminate\Support\Facades\Route; | */ -Route::middleware('auth:api')->get('/user', function (Request $request) { - return $request->user(); +Route::middleware('auth:api')->group(function () { + Route::get('/regiones', function() { + return GrupoDeCompra::$regiones; + }); });