0% found this document useful (0 votes)
68 views5 pages

17 Julio Commit Apptalento

1. The commit modifies tables related to users and their CRUD (create, read, update, delete) operations in the application. 2. It adds fields like first name, last name to the users table and identification type to link users to types like ID card, passport. 3. It also creates identification type records like ID card, passport and links them to users.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
68 views5 pages

17 Julio Commit Apptalento

1. The commit modifies tables related to users and their CRUD (create, read, update, delete) operations in the application. 2. It adds fields like first name, last name to the users table and identification type to link users to types like ID card, passport. 3. It also creates identification type records like ID card, passport and links them to users.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

1/8/2020 Inicio de Modificaciones a tabla usuario y su CRUD (f91dba16) · Commits · Guillermo Agudelo / apptalento · GitLab

Please ensure your account's recovery settings are up to date.

Commit f91dba16 authored 2 weeks ago by Guillermo Agudelo

Inicio de Modificaciones a tabla usuario y su CRUD

parent 5cef83ed master

No related merge requests found

Showing 9 changed files  with 167 additions and 17 deletions

  app/Http/Controllers/Admin/UserController.php
... ... @@ -4,6 +4,7 @@ namespace App\Http\Controllers\Admin;
4 4
5 5 use App\Http\Controllers\Controller;
6 6 use App\Models\Client;
7 + use App\Models\IdentificationType;
7 8 use App\Models\Plan;
8 9 use App\User;
9 10 use Illuminate\Http\Request;
... ... @@ -30,8 +31,9 @@ class UserController extends Controller
30 31
31 32 public function create()
32 33 {
34 + $identificationTypes = IdentificationType::all();
33 35 $clients = Client::orderBy('name')->get();
34 - return view('admin.users.create', compact('clients'));
36 + return view('admin.users.create', compact('clients', 'identificationTypes'));
35 37 }
36 38
37 39 public function store(Request $request)
... ...

  app/Models/IdentificationType.php 0 → 100644

1 + <?php
2 +
3 + namespace App\Models;
4 +
5 + use Illuminate\Database\Eloquent\Model;
6 +
7 + class IdentificationType extends Model
8 +{
9 + //
10 +}

  app/User.php
... ... @@ -41,6 +41,10 @@ class User extends Authenticatable
41 41 'email_verified_at' => 'datetime',
42 42 ];
43 43
44 + public function getNameAttribute()
45 + {
46 + return "{$this->first_name} {$this->last_name}";
47 + }
44 48
45 49 public function accessLogs()
46 50 {
... ...

  database/factories/UserFactory.php
... ... @@ -20,7 +20,8 @@ use Illuminate\Support\Str;
20 20
21 21 $factory->define(User::class, function (Faker $faker) {

https://gitlab.com/guille.agudelo/apptalento/-/commit/f91dba164b0ffd2b48b69f16ddd783a230464b43 1/5
1/8/2020 Inicio de Modificaciones a tabla usuario y su CRUD (f91dba16) · Commits · Guillermo Agudelo / apptalento · GitLab

22 22 return [
23 - 'name' => $faker->name,
23 + 'first_name' => $faker->firstName,
24 + 'last_name' => $faker->lastName,
24 25 'email' => $faker->unique()->safeEmail,
25 26 'email_verified_at' => now(),
26 27 'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
... ...

  database/migrations/2020_07_13_083800_create_identification_types_table.php 0 → 100644
1 + <?php
2 +
3 + use Illuminate\Database\Migrations\Migration;
4 + use Illuminate\Database\Schema\Blueprint;
5 + use Illuminate\Support\Facades\DB;
6 + use Illuminate\Support\Facades\Schema;
7 +
8 + class CreateIdentificationTypesTable extends Migration
9 +{
10 + /**
11 + * Run the migrations.
12 + *
13 + * @return void
14 + */
15 + public function up()
16 + {
17 + Schema::create('identification_types', function (Blueprint $table) {
18 + $table->id();
19 + $table->string('name');
20 + $table->string('description');
21 + $table->timestamps();
22 + });
23 +
24 + DB::table('identification_types')->insert([
25 + 'name' => 'RC',
26 + 'description' => 'Registro Civil',
27 + 'created_at' => now(),
28 + 'updated_at' => now()
29 + ]);
30 +
31 + DB::table('identification_types')->insert([
32 + 'name' => 'TI',
33 + 'description' => 'Tarjeta de Identidad',
34 + 'created_at' => now(),
35 + 'updated_at' => now()
36 + ]);
37 +
38 + DB::table('identification_types')->insert([
39 + 'name' => 'CC',
40 + 'description' => 'Cédula de Ciudadanía',
41 + 'created_at' => now(),
42 + 'updated_at' => now()
43 + ]);
44 +
45 + DB::table('identification_types')->insert([
46 + 'name' => 'CE',
47 + 'description' => 'Cédula de Extranjería',
48 + 'created_at' => now(),
49 + 'updated_at' => now()
50 + ]);
51 +
52 + DB::table('identification_types')->insert([
53 + 'name' => 'MS',
54 + 'description' => 'Menor sin Identificación',
55 + 'created_at' => now(),
56 + 'updated_at' => now()
57 + ]);
58 +
59 + DB::table('identification_types')->insert([
60 + 'name' => 'AS',
61 + 'description' => 'Adulto sin Identificación',
62 + 'created_at' => now(),
63 + 'updated_at' => now()
64 + ]);

https://gitlab.com/guille.agudelo/apptalento/-/commit/f91dba164b0ffd2b48b69f16ddd783a230464b43 2/5
1/8/2020 Inicio de Modificaciones a tabla usuario y su CRUD (f91dba16) · Commits · Guillermo Agudelo / apptalento · GitLab

65 +
66 + }
67 +
68 + /**
69 + * Reverse the migrations.
70 + *
71 + * @return void
72 + */
73 + public function down()
74 + {
75 + Schema::dropIfExists('identification_types');
76 + }
77 +}

  database/migrations/2020_07_13_084000_create_users_table.php

... ... @@ -15,18 +15,26 @@ class CreateUsersTable extends Migration


15 15 {
16 16 Schema::create('users', function (Blueprint $table) {
17 17 $table->id();
18 - $table->string('name');
18 + $table->string('first_name');
19 + $table->string('last_name');
19 20 $table->string('email')->unique();
20 21 $table->timestamp('email_verified_at')->nullable();
21 22 $table->string('password');
22 23 $table->enum('type', UserTypes::getConstants());
24 + $table->foreignId('identification_type_id')->nullable();
25 + $table->string('identification')->nullable();
26 + $table->date('birthday')->nullable();
27 + $table->enum('sex', ['M', 'F'])->nullable();
28 + $table->string('phone')->nullable();
23 29 $table->foreignId('client_id');
30 + $table->boolean('active')->default(true);
24 31 $table->rememberToken();
25 32 $table->timestamps();
26 33 });
27 34
28 35 \DB::table('users')->insert([
29 - 'name' => 'Super Administrador',
36 + 'first_name' => 'Super',
37 + 'last_name' => 'Administrador',
30 38 'email' => '[email protected]',
31 39 'password' => Hash::make('secret'),
32 40 'type' => UserTypes::SUPERADMIN,
... ...

  database/seeds/UsersTableSeeder.php

... ... @@ -14,7 +14,8 @@ class UsersTableSeeder extends Seeder


14 14 {
15 15
16 16 DB::table('users')->insert([
17 - 'name' => 'Jonatan Gutiérrez',
17 + 'first_name' => 'Jonatan',
18 + 'last_name' => 'Gutiérrez',
18 19 'email' => '[email protected]',
19 20 'email_verified_at' => now(),
20 21 'password' => Hash::make('secret'),
... ... @@ -25,7 +26,8 @@ class UsersTableSeeder extends Seeder
25 26 ]);
26 27
27 28 DB::table('users')->insert([
28 - 'name' => 'María González',
29 + 'first_name' => 'María',
30 + 'last_name' => 'González',
29 31 'email' => '[email protected]',
30 32 'email_verified_at' => now(),
31 33 'password' => Hash::make('secret'),
... ... @@ -36,7 +38,8 @@ class UsersTableSeeder extends Seeder
36 38 ]);
37 39
38 40 DB::table('users')->insert([
39 - 'name' => 'Esperanza López',
41 + 'first_name' => 'Esperanza',

https://gitlab.com/guille.agudelo/apptalento/-/commit/f91dba164b0ffd2b48b69f16ddd783a230464b43 3/5
1/8/2020 Inicio de Modificaciones a tabla usuario y su CRUD (f91dba16) · Commits · Guillermo Agudelo / apptalento · GitLab

42 + 'last_name' => 'López',


40 43 'email' => '[email protected]',
41 44 'email_verified_at' => now(),
42 45 'password' => Hash::make('secret'),
... ... @@ -47,7 +50,8 @@ class UsersTableSeeder extends Seeder
47 50 ]);
48 51
49 52 DB::table('users')->insert([
50 - 'name' => 'Ruben Pérez',
53 + 'first_name' => 'Ruben',
54 + 'last_name' => 'Pérez',
51 55 'email' => '[email protected]',
52 56 'email_verified_at' => now(),
53 57 'password' => Hash::make('secret'),
... ... @@ -58,7 +62,8 @@ class UsersTableSeeder extends Seeder
58 62 ]);
59 63
60 64 DB::table('users')->insert([
61 - 'name' => 'Fabián López',
65 + 'first_name' => 'Fabián',
66 + 'last_name' => 'López',
62 67 'email' => '[email protected]',
63 68 'email_verified_at' => now(),
64 69 'password' => Hash::make('secret'),
... ...

  notas.txt
1 - . footer
1 + . solo superadmin, y admins pueden iniciar sesion
2 + . los demas roles seciben un link para hacer la prueba
2 3

  resources/views/admin/users/create.blade.php
... ... @@ -2,15 +2,57 @@
2 2 @section('content')
3 3 <div class="container" id="users">
4 4
5 - <form action="{{route('admin.users.store')}}" method="post" style="max-width:400px" class="mx-4 my-
5">
5 + <p>Los campos marcados con asterisco (*) son obligatorios</p>
6 +
7 + <form action="{{route('admin.users.store')}}"
8 + method="post"
9 + class="mx-4 p-3 border rounded">
6 10 @csrf
7 11
8 - <div class="form-group">
9 - <label for="">Nombre</label>
10 - <input type="text" class="form-control" name="name" value="{{old('name', '')}}" required>
11 - @error('name')
12 - <span class="text-danger">{{$message}}</span>
13 - @enderror
12 + <h2>Información básica</h2>
13 + <div class="row">
14 + <div class="col-lg-6">
15 + <div class="form-group">
16 + <label for="">Nombres *</label>
17 + <input type="text" class="form-control" name="first_name" value="
{{old('first_name', '')}}" required>
18 + @error('first_name')
19 + <span class="text-danger">{{$message}}</span>
20 + @enderror
21 + </div>
22 +
23 + <div class="form-group">
24 + <label for="">Apellidos *</label>
25 + <input type="text" class="form-control" name="last_name" value="{{old('last_name',
'')}}" required>
26 + @error('last_name')
27 + <span class="text-danger">{{$message}}</span>
28 + @enderror
29 + </div>
30 + </div>

https://gitlab.com/guille.agudelo/apptalento/-/commit/f91dba164b0ffd2b48b69f16ddd783a230464b43 4/5
1/8/2020 Inicio de Modificaciones a tabla usuario y su CRUD (f91dba16) · Commits · Guillermo Agudelo / apptalento · GitLab

31 +
32 + <div class="col-lg-6">
33 + <div class="form-group">
34 + <label for="">Tipo de Identificación</label>
35 + <select id="" name="identification_type_id" class="form-control">
36 + <option value=""></option>
37 + @foreach($identificationTypes as $type)
38 + <option value="{{$type->id}}">
39 + {{$type->name}} - {{$type->description}}
40 + </option>
41 + @endforeach
42 + </select>
43 + @error('last_name')
44 + <span class="text-danger">{{$message}}</span>
45 + @enderror
46 + </div>
47 +
48 + <div class="form-group">
49 + <label for="">Número de Identificación</label>
50 + <input type="text" class="form-control" name="identification" value="
{{old('identification', '')}}">
51 + @error('identification')
52 + <span class="text-danger">{{$message}}</span>
53 + @enderror
54 + </div>
55 + </div>
14 56 </div>
15 57
16 58 <div class="form-group">
... ...

Write a comment or drag your files here…

Markdown and quick actions are supported

https://gitlab.com/guille.agudelo/apptalento/-/commit/f91dba164b0ffd2b48b69f16ddd783a230464b43 5/5

You might also like