Correcciones Validator Plan Controller/ unique multiple codigo, plan_id
This commit is contained in:
parent
273133ee93
commit
111c0a0bb0
@ -3,6 +3,7 @@
|
|||||||
namespace App\Http\Controllers\Api;
|
namespace App\Http\Controllers\Api;
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Validation\Rule;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use App\Models\plan;
|
use App\Models\plan;
|
||||||
use App\Models\AccionesMejoras;
|
use App\Models\AccionesMejoras;
|
||||||
@ -22,35 +23,41 @@ class PlanController extends Controller{
|
|||||||
public function createPlan(Request $request){
|
public function createPlan(Request $request){
|
||||||
$request->validate([
|
$request->validate([
|
||||||
"estandar_id"=> "required|integer",
|
"estandar_id"=> "required|integer",
|
||||||
"nombre"=>"required|max:255",
|
"nombre"=>"present|max:255",
|
||||||
"codigo"=> "required|max:11",
|
/* "codigo"=> "required|unique_with:plans,id_estandar|max:11", */
|
||||||
"fuentes"=>"required",
|
'codigo' => [
|
||||||
/* "fuentes.*.descripcion"=> "required", */
|
'required',
|
||||||
"problemas_oportunidades"=>"required",
|
Rule::unique('plans', 'codigo')->where(function ($query) use ($request) {
|
||||||
/* "problemas_oportunidades.*.descripcion"=> "required", */
|
return $query->where('id_estandar', $request->estandar_id);
|
||||||
"causas_raices"=>"required",
|
}),
|
||||||
/* "causas_raices.*.descripcion"=> "required", */
|
],
|
||||||
"oportunidad_plan"=>"required|max:255",
|
"fuentes"=>"present",
|
||||||
"acciones_mejoras"=>"required",
|
"fuentes.*.descripcion"=> "required",
|
||||||
/* "acciones_mejoras.*.descripcion"=> "required", */
|
"problemas_oportunidades"=>"present",
|
||||||
"semestre_ejecucion"=>"required|max:8", //aaaa-A/B/C/AB
|
"problemas_oportunidades.*.descripcion"=> "required",
|
||||||
"duracion"=> "required|integer",
|
"causas_raices"=>"present",
|
||||||
"recursos"=>"required",
|
"causas_raices.*.descripcion"=> "required",
|
||||||
/* "recursos.*.descripcion"=> "required", */
|
"oportunidad_plan"=>"present|max:255",
|
||||||
"metas"=>"required",
|
"acciones_mejoras"=>"present",
|
||||||
/* "metas.*.descripcion"=> "required", */
|
"acciones_mejoras.*.descripcion"=> "required",
|
||||||
"responsables"=>"required",
|
"semestre_ejecucion"=>"present|max:8", //aaaa-A/B/C/AB
|
||||||
/* "responsables.*.nombre"=> "required", */
|
"duracion"=> "present|integer",
|
||||||
"observaciones"=>"required",
|
"recursos"=>"present",
|
||||||
/* "observaciones.*.descripcion"=> "required", */
|
"recursos.*.descripcion"=> "required",
|
||||||
"estado"=> "required|max:30",
|
"metas"=>"present",
|
||||||
|
"metas.*.descripcion"=> "required",
|
||||||
|
"responsables"=>"present",
|
||||||
|
"responsables.*.nombre"=> "required",
|
||||||
|
"observaciones"=>"present",
|
||||||
|
"observaciones.*.descripcion"=> "required",
|
||||||
|
"estado"=> "present|max:30",
|
||||||
/*"evidencias_planes_mejoras"=>"required",
|
/*"evidencias_planes_mejoras"=>"required",
|
||||||
"evidencias_planes_mejoras.*.codigo"=> "required",
|
"evidencias_planes_mejoras.*.codigo"=> "required",
|
||||||
"evidencias_planes_mejoras.*.denominacion"=> "required",
|
"evidencias_planes_mejoras.*.denominacion"=> "required",
|
||||||
"evidencias_planes_mejoras.*.encargado_id"=> "required",
|
"evidencias_planes_mejoras.*.encargado_id"=> "required",
|
||||||
"evidencias_planes_mejoras*.adjunto"=> "required",*/
|
"evidencias_planes_mejoras*.adjunto"=> "required",*/
|
||||||
"evaluacion_eficacia"=> "required|boolean",
|
"evaluacion_eficacia"=> "present|boolean",
|
||||||
"avance"=> "required|integer"
|
"avance"=> "present|integer"
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$id_user = auth()->user()->id;
|
$id_user = auth()->user()->id;
|
||||||
|
573
composer.lock
generated
573
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@ -16,17 +16,18 @@ public function up()
|
|||||||
Schema::create('plans', function (Blueprint $table) {
|
Schema::create('plans', function (Blueprint $table) {
|
||||||
$table->id();
|
$table->id();
|
||||||
$table->string('codigo', 11);
|
$table->string('codigo', 11);
|
||||||
$table->string('nombre');
|
$table->string('nombre',255)->nullable();
|
||||||
$table->string('oportunidad_plan');
|
$table->string('oportunidad_plan')->nullable();
|
||||||
$table->string('semestre_ejecucion', 7);
|
$table->string('semestre_ejecucion', 8)->nullable();
|
||||||
$table->integer('avance');
|
$table->integer('avance')->nullable();
|
||||||
$table->integer('duracion');
|
$table->integer('duracion');
|
||||||
$table->string('estado', 30);
|
$table->string('estado', 30)->nullable();
|
||||||
$table->boolean('evaluacion_eficacia');
|
$table->boolean('evaluacion_eficacia');
|
||||||
$table->foreignId('id_estandar')
|
$table->foreignId('id_estandar')
|
||||||
->constrained('estandars');
|
->constrained('estandars');
|
||||||
$table->foreignId('id_user')
|
$table->foreignId('id_user')
|
||||||
->constrained('users');
|
->constrained('users');
|
||||||
|
$table->unique(['codigo', 'id_estandar']);
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user