Se adjuntan columnas de apellido paterno y materno para el usuario y validaciones de registro de usuario independiente
This commit is contained in:
@@ -16,28 +16,27 @@ class CreateNewUser implements CreatesNewUsers
|
|||||||
|
|
||||||
public function create(array $input)
|
public function create(array $input)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if( $input['plantels'] == 0){
|
||||||
|
throw ValidationException::withMessages([
|
||||||
|
'plantels' => ['Debes elegir un plantel']
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
Validator::make($input, [
|
Validator::make($input, [
|
||||||
'name' => ['required', 'string', 'max:255'],
|
'name' => ['required', 'string', 'max:255'],
|
||||||
|
'apellidoPaterno' => ['required', 'string', 'max:255'],
|
||||||
|
'apellidoMaterno' => ['required', 'string', 'max:255'],
|
||||||
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
|
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
|
||||||
'telefono' => ['required', 'digits:10', 'unique:users,telefono'],
|
'telefono' => ['required', 'digits:10', 'unique:users,telefono'],
|
||||||
'password' => $this->passwordRules(),
|
'password' => $this->passwordRules(),
|
||||||
'terms' => Jetstream::hasTermsAndPrivacyPolicyFeature() ? ['accepted', 'required'] : '',
|
'terms' => Jetstream::hasTermsAndPrivacyPolicyFeature() ? ['accepted', 'required'] : '',
|
||||||
])->validate();
|
])->validate();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (User::where('email', $input['email'])
|
|
||||||
->orWhere('telefono', $input['telefono'])
|
|
||||||
->exists()) {
|
|
||||||
|
|
||||||
throw ValidationException::withMessages([
|
|
||||||
'email' => ['El correo o teléfono ya están registrados.']
|
|
||||||
]);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
$user = User::create([
|
$user = User::create([
|
||||||
'name' => $input['name'],
|
'name' => $input['name'],
|
||||||
|
'apellidoPaterno' => $input['apellidoPaterno'],
|
||||||
|
'apellidoMaterno' => $input['apellidoMaterno'],
|
||||||
'email' => $input['email'],
|
'email' => $input['email'],
|
||||||
'telefono' => $input['telefono'],
|
'telefono' => $input['telefono'],
|
||||||
'direccion' => "",
|
'direccion' => "",
|
||||||
@@ -59,8 +58,6 @@ class CreateNewUser implements CreatesNewUsers
|
|||||||
|
|
||||||
$prospecto->prospectos()->sync([$user->id]);
|
$prospecto->prospectos()->sync([$user->id]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return $user;
|
return $user;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,6 +44,8 @@ class UserController extends Controller
|
|||||||
|
|
||||||
$user = User::create([
|
$user = User::create([
|
||||||
'name' => $request->name,
|
'name' => $request->name,
|
||||||
|
'apellidoPaterno' => $request-> apellidoPaterno,
|
||||||
|
'apellidoMaterno' => $request-> apellidoMaterno,
|
||||||
'email' => $request->email,
|
'email' => $request->email,
|
||||||
'telefono' => $request->telefono ?? null,
|
'telefono' => $request->telefono ?? null,
|
||||||
'direccion' => $request->direccion ?? null,
|
'direccion' => $request->direccion ?? null,
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ class User extends Authenticatable
|
|||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'name',
|
'name',
|
||||||
|
'apellidoPaterno',
|
||||||
|
'apellidoMaterno',
|
||||||
'email',
|
'email',
|
||||||
'telefono',
|
'telefono',
|
||||||
'direccion',
|
'direccion',
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ return new class extends Migration
|
|||||||
Schema::create('users', function (Blueprint $table) {
|
Schema::create('users', function (Blueprint $table) {
|
||||||
$table->id();
|
$table->id();
|
||||||
$table->string('name');
|
$table->string('name');
|
||||||
|
$table->string('apellidoPaterno');
|
||||||
|
$table->string('apellidoMaterno');
|
||||||
$table->string('email')->unique();
|
$table->string('email')->unique();
|
||||||
$table->timestamp('email_verified_at')->nullable();
|
$table->timestamp('email_verified_at')->nullable();
|
||||||
$table->string('telefono',20)->nullable()->unique();
|
$table->string('telefono',20)->nullable()->unique();
|
||||||
|
|||||||
@@ -14,7 +14,9 @@ class UserSeeder extends Seeder
|
|||||||
public function run(): void
|
public function run(): void
|
||||||
{
|
{
|
||||||
$user1= User::create([
|
$user1= User::create([
|
||||||
'name'=>'Luis Fernando Pérez',
|
'name'=>'Luis Fernando',
|
||||||
|
'apellidoPaterno'=>'Pérez',
|
||||||
|
'apellidoMaterno'=>'Luna',
|
||||||
'email'=>'fernandoestrp@outlook.es',
|
'email'=>'fernandoestrp@outlook.es',
|
||||||
'direccion'=>'Zacatenco mz 21 lt 2 san francisco cuautliquixca',
|
'direccion'=>'Zacatenco mz 21 lt 2 san francisco cuautliquixca',
|
||||||
'telefono'=>'5636287759',
|
'telefono'=>'5636287759',
|
||||||
@@ -26,7 +28,9 @@ class UserSeeder extends Seeder
|
|||||||
$user1->plantelUsuarios()->sync(1);
|
$user1->plantelUsuarios()->sync(1);
|
||||||
|
|
||||||
$user2= User::create([
|
$user2= User::create([
|
||||||
'name'=>'Antonio Azulito Real Luna',
|
'name'=>'Antonio Azulito',
|
||||||
|
'apellidoPaterno'=>'Real',
|
||||||
|
'apellidoMaterno'=>'Luna',
|
||||||
'email'=>'reydelfin@gmail.com',
|
'email'=>'reydelfin@gmail.com',
|
||||||
'direccion'=>'Zacatenco mz 21 lt 2 san francisco cuautliquixca',
|
'direccion'=>'Zacatenco mz 21 lt 2 san francisco cuautliquixca',
|
||||||
'telefono'=>'5636287758',
|
'telefono'=>'5636287758',
|
||||||
|
|||||||
@@ -37,14 +37,24 @@
|
|||||||
<select class="form-control" name="plantels" id="plantels" >
|
<select class="form-control" name="plantels" id="plantels" >
|
||||||
<option value="0" >Selecciona un plantel</option>
|
<option value="0" >Selecciona un plantel</option>
|
||||||
@foreach($plantels as $plantel)
|
@foreach($plantels as $plantel)
|
||||||
<option value="{{ $plantel->id }}">{{ $plantel->name }}</option>
|
<option value="{{ $plantel->id }}" {{ old('plantels') == $plantel->id ? 'selected' : '' }}>{{ $plantel->name }}</option>
|
||||||
@endforeach
|
@endforeach
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>Nombre</label>
|
<label>Nombres</label>
|
||||||
<input type="name" class="form-control form-control-user" id="name" name="name" placeholder="Nombre" required autofocus autocomplete="name">
|
<input type="text" class="form-control form-control-user" id="name" name="name" placeholder="Nombre" required autofocus value="{{ old('name') }}">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Apellido Paterno</label>
|
||||||
|
<input type="text" class="form-control form-control-user" id="apellidoPaterno" name="apellidoPaterno" placeholder="Apellido Paterno" required autofocus value="{{ old('apellidoPaterno') }}">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Apellido Materno</label>
|
||||||
|
<input type="text" class="form-control form-control-user" id="apellidoMaterno" name="apellidoMaterno" placeholder="Apellido Materno" required autofocus value="{{ old('apellidoMaterno') }}">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
@@ -54,7 +64,7 @@
|
|||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>Teléfono</label>
|
<label>Teléfono</label>
|
||||||
<input type="text" class="form-control form-control-user" name="telefono" maxlength="10" onkeypress="return event.charCode >= 48 && event.charCode <= 57" inputmode="numeric" autocomplete="off" required>
|
<input type="text" class="form-control form-control-user" name="telefono" maxlength="10" onkeypress="return event.charCode >= 48 && event.charCode <= 57" inputmode="numeric" value="{{ old('telefono') }}" required>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
|||||||
@@ -4,8 +4,7 @@
|
|||||||
<html lang="es">
|
<html lang="es">
|
||||||
<head>
|
<head>
|
||||||
@include('layouts._partials.head')
|
@include('layouts._partials.head')
|
||||||
@vite([ 'resources/js/app.js'])
|
{{-- @vite([ 'resources/js/app.js']) --}}
|
||||||
|
|
||||||
|
|
||||||
{{-- Livewire styles --}}
|
{{-- Livewire styles --}}
|
||||||
@livewireStyles
|
@livewireStyles
|
||||||
|
|||||||
@@ -21,6 +21,16 @@
|
|||||||
<input class="form-control" name="name">
|
<input class="form-control" name="name">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<label class="small mb-1">Apellido Paterno</label>
|
||||||
|
<input class="form-control" name="apellidoPaterno">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<label class="small mb-1">Apellido Materno</label>
|
||||||
|
<input class="form-control" name="apellidoMaterno">
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label class="small mb-1">Correo</label>
|
<label class="small mb-1">Correo</label>
|
||||||
<input class="form-control" name="email">
|
<input class="form-control" name="email">
|
||||||
|
|||||||
@@ -27,6 +27,16 @@
|
|||||||
<input class="form-control" name="name" value="{{$user->name}}">
|
<input class="form-control" name="name" value="{{$user->name}}">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<label class="small mb-1">Apellido Paterno</label>
|
||||||
|
<input class="form-control" name="apellidoPaterno" value="{{$user->apellidoPaterno}}">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<label class="small mb-1">Apellido Materno</label>
|
||||||
|
<input class="form-control" name="apellidoMaterno" value="{{$user->apellidoMaterno}}">
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label class="small mb-1">Correo</label>
|
<label class="small mb-1">Correo</label>
|
||||||
<input class="form-control" name="email" value="{{$user->email}}">
|
<input class="form-control" name="email" value="{{$user->email}}">
|
||||||
|
|||||||
+6
-10
@@ -1,7 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Broadcast;
|
use Illuminate\Support\Facades\Broadcast;
|
||||||
use App\Models\Conversation;
|
use App\Models\Conversation;
|
||||||
|
|
||||||
Broadcast::channel('App.Models.User.{id}', function ($user, $id) {
|
Broadcast::channel('App.Models.User.{id}', function ($user, $id) {
|
||||||
return (int) $user->id === (int) $id;
|
return (int) $user->id === (int) $id;
|
||||||
@@ -10,12 +9,9 @@ Broadcast::channel('App.Models.User.{id}', function ($user, $id) {
|
|||||||
Broadcast::channel('chat.{conversationId}', function ($user, $conversationId) {
|
Broadcast::channel('chat.{conversationId}', function ($user, $conversationId) {
|
||||||
|
|
||||||
return Conversation::where('id', $conversationId)
|
return Conversation::where('id', $conversationId)
|
||||||
->whereHas('users', fn ($q) =>
|
->whereHas('users', function ($q) use ($user) {
|
||||||
$q->where('user_id', $user->id)
|
$q->where('user_id', $user->id);
|
||||||
)->exists();
|
})
|
||||||
|
->exists();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Broadcast::channel('chat.{conversationId}', function ($user, $conversationId) {return Conversation::where('id', $conversationId)->whereHas('users', function ($q) use ($user) {$q->where('user_id', $user->id);})->exists();});
|
|
||||||
|
|||||||
Reference in New Issue
Block a user