master
sergeybodin 2023-09-07 14:22:07 +03:00
parent f727628fd6
commit c9fb77d332
4 changed files with 57 additions and 8 deletions

View File

@ -26,7 +26,9 @@ class Application extends Model {
'product_id',
'status',
'number',
'applicant'
'applicant',
'email',
'phone',
];
protected $hidden = [

View File

@ -49,6 +49,20 @@ class ApplicationForms extends FormsService {
'required' => true,
'value' => $model->applicant ?? null
],
[
'name' => 'email',
'title' => 'Email',
'type' => FieldType::STRING,
'required' => true,
'value' => $model->phone ?? null
],
[
'name' => 'phone',
'title' => 'Телефон',
'type' => FieldType::STRING,
'required' => true,
'value' => $model->phone ?? null
],
[
'name' => 'product_name',
'title' => 'Hаименование продукции',
@ -70,12 +84,6 @@ class ApplicationForms extends FormsService {
'required' => true,
'value' => $model->product->usage ?? null
],
[
'name' => 'normative',
'title' => 'Нормативно-технический документ',
'type' => FieldType::STRING,
'value' => $model->product->normative ?? null
],
[
'name' => 'producer',
'title' => 'Изготовитель/разработчик',
@ -117,7 +125,11 @@ class ApplicationForms extends FormsService {
}
public function updateData(Application $model, array $data) {
$model->update(['applicant' => $data['applicant'] ?? null]);
$model->update([
'applicant' => $data['applicant'] ?? null,
'email' => $data['email'] ?? null,
'phone' => $data['phone'] ?? null
]);
$model->product->update(['name' => $data['product_name'] ?? null, 'purpose' => $data['product_purpose'] ?? null, 'usage' => $data['product_usage'] ?? null,
'normative' => $data['normative'] ?? null, 'producer' => $data['producer'] ?? null]);
$model->properties->setValue('documents', $data['documents'] ?? null);

View File

@ -26,6 +26,8 @@ class ApplicationTransformer extends TransformerAbstract {
'status' => $model->parsedStatus,
'number' => $model->number,
'applicant' => $model->applicant,
'email' => $model->email,
'phone' => $model->phone,
'created_at' => $model->created_at ? $model->created_at->toIso8601String() : null,
'updated_at' => $model->updated_at ? $model->updated_at->toIso8601String() : null
];

View File

@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddInApplicationsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('applications', function (Blueprint $table) {
$table->string('email')->index()->nullable()->after('applicant');
$table->string('phone')->index()->nullable()->after('email');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('applications', function (Blueprint $table) {
$table->dropColumn(['email', 'phone']);
});
}
}