Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Organization): Modificacion de campos: ruc, address y phone #209

Merged
merged 1 commit into from
Nov 17, 2023
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
10 changes: 5 additions & 5 deletions app/Http/Controllers/OrganizationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,13 @@ public function update(UpdateOrganizationRequest $request, Organization $organiz
}
$organization->update([
'name' => $request['name']??$organization->name,
'ruc' => $request['ruc']??$organization->ruc,
'address' => $request['address']??$organization->address,
'ruc' => $request['ruc'],
'address' => $request['address'],
'sector_id' => $request['sector_id']??$organization->sector_id,
'municipality_id' => $request['municipality_id']??$organization->municipality_id,
'city_id' => $request['city_id']??$organization->city_id,
'phone_main' => $request['phone_main']??$organization->phone_main,
'phone_secondary' => $request['phone_secondary']??$organization->phone_secondary,
'phone_main' => $request['phone_main'],
'phone_secondary' => $request['phone_secondary'],
'image' => $new_image??$organization->image,
]);
DB::commit();
Expand Down Expand Up @@ -269,7 +269,7 @@ public function update_my_organization(UpdateMyOrganizationRequest $request){
}
$organization->update([
'name' => $request['name']??$organization->name,
'ruc' => $request['ruc']??$organization->ruc,
'ruc' => $request['ruc'],
'address' => $request['address'],
'sector_id' => $request['sector_id']??$organization->sector_id,
'municipality_id' => $request['municipality_id']??$organization->municipality_id,
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Requests/Organization/StoreOrganizationRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ public function rules(): array
{
return [
"name" => "required|string|unique:organizations,name",
"ruc" => "required|string|unique:organizations,ruc|max:14",
"ruc" => "nullable|string|unique:organizations,ruc|max:14",
"address" => "nullable|string",
"sector_id" => "required|integer|exists:sectors,id",
"municipality_id" => "required|integer|exists:municipalities,id",
"city_id" => "required|integer|exists:cities,id",
"phone_main" => "required|string",
"phone_main" => "nullable|string",
"phone_secondary" => "nullable|string",
"image" => "nullable|image|mimes:jpeg,png,jpg,svg|max:2048",
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ public function rules(): array
"ruc" => [
"string",
"unique:organizations,ruc",
"max:14"
"max:14",
"nullable"
],
"address" => [
"nullable",
Expand All @@ -56,6 +57,7 @@ public function rules(): array
],
"phone_main" => [
"string",
"nullable"
],
"phone_secondary" => [
"nullable",
Expand Down
4 changes: 3 additions & 1 deletion app/Http/Requests/Organization/UpdateOrganizationRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ public function rules(): array
"ruc" => [
"string",
Rule::unique('organizations', 'ruc')->ignore($id, 'id'),
"max:14"
"max:14",
"nullable"
],
"address" => [
"nullable",
Expand All @@ -70,6 +71,7 @@ public function rules(): array
new MatchOldCity($organization->city_id)
],
"phone_main" => [
"nullable",
"string",
new MatchOldPhoneMain($organization->phone_main),
],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?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::table('organizations', function (Blueprint $table) {
$table->string('address')->nullable()->change();
$table->string('phone_main')->nullable()->change();
$table->string('ruc', 16)->nullable()->change();
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('organizations', function (Blueprint $table) {
$table->string('address')->nullable(false)->change();
$table->string('phone_main')->nullable(false)->change();
$table->string('ruc', 16)->nullable(false)->change();
});
}
};
Loading