From e9f3fdfd3845568a40ff1d754a6130ed64b83c28 Mon Sep 17 00:00:00 2001 From: ilmedova Date: Wed, 6 Jul 2022 13:08:56 +0500 Subject: [PATCH] Client added to login, admin panel finished --- .../Admin/AttachmentCrudController.php | 26 +++++--- .../Admin/DocumentCrudController.php | 61 +++++++++++++------ .../Admin/DocumentgroupCrudController.php | 60 ++++++++++++------ .../Admin/QuestionCrudController.php | 35 ++++++----- app/Http/Controllers/AuthController.php | 2 +- app/Models/Document.php | 10 ++- app/Models/Documentgroup.php | 10 ++- app/Models/Question.php | 5 +- 8 files changed, 142 insertions(+), 67 deletions(-) diff --git a/app/Http/Controllers/Admin/AttachmentCrudController.php b/app/Http/Controllers/Admin/AttachmentCrudController.php index 8583d39c..fe5b0785 100644 --- a/app/Http/Controllers/Admin/AttachmentCrudController.php +++ b/app/Http/Controllers/Admin/AttachmentCrudController.php @@ -39,13 +39,7 @@ public function setup() */ protected function setupListOperation() { - - - /** - * Columns can be defined using the fluent syntax or array syntax: - * - CRUD::column('price')->type('number'); - * - CRUD::addColumn(['name' => 'price', 'type' => 'number']); - */ + $this->crud->setFromDb(); } /** @@ -79,7 +73,23 @@ protected function setupCreateOperation() 'type' => 'upload', 'upload' => true, 'disk' => 'uploads', // if you store files in the /public folder, please ommit this; if you store them in /storage or S3, please specify it; - ] + ], + [ + 'name' => 'document_id', + 'type' => 'select', + 'label' => 'Document', + 'entity' => 'document', + 'model' => "App\Models\Document", + 'attribute' => 'name_ru' + ], + [ + 'name' => 'application_id', + 'type' => 'select', + 'label' => 'Application', + 'entity' => 'application', + 'model' => "App\Models\Application", + 'attribute' => 'account_id' + ], ]); } diff --git a/app/Http/Controllers/Admin/DocumentCrudController.php b/app/Http/Controllers/Admin/DocumentCrudController.php index da2e7d20..c57de628 100644 --- a/app/Http/Controllers/Admin/DocumentCrudController.php +++ b/app/Http/Controllers/Admin/DocumentCrudController.php @@ -21,7 +21,7 @@ class DocumentCrudController extends CrudController /** * Configure the CrudPanel object. Apply settings to all operations. - * + * * @return void */ public function setup() @@ -33,43 +33,66 @@ public function setup() /** * Define what happens when the List operation is loaded. - * + * * @see https://backpackforlaravel.com/docs/crud-operation-list-entries * @return void */ protected function setupListOperation() { - - - /** - * Columns can be defined using the fluent syntax or array syntax: - * - CRUD::column('price')->type('number'); - * - CRUD::addColumn(['name' => 'price', 'type' => 'number']); - */ + $this->crud->setFromDb(); } /** * Define what happens when the Create operation is loaded. - * + * * @see https://backpackforlaravel.com/docs/crud-operation-create * @return void */ protected function setupCreateOperation() { CRUD::setValidation(DocumentRequest::class); - - - - /** - * Fields can be defined using the fluent syntax or array syntax: - * - CRUD::field('price')->type('number'); - * - CRUD::addField(['name' => 'price', 'type' => 'number'])); - */ + $this->crud->addFields([ + [ + 'name' => 'name_ru', + 'type' => 'text', + 'label' => 'Name ru' + ], + [ + 'name' => 'name_en', + 'type' => 'text', + 'label' => 'Name en' + ], + [ + 'name' => 'name_tm', + 'type' => 'text', + 'label' => 'Name tm' + ], + [ + 'name' => 'description_ru', + 'type' => 'textarea', + 'label' => 'Description ru' + ], + [ + 'name' => 'description_en', + 'type' => 'textarea', + 'label' => 'Description en' + ], + [ + 'name' => 'description_tm', + 'type' => 'textarea', + 'label' => 'Description tm' + ], + [ + 'name' => 'max_size', + 'type' => 'text', + 'label' => 'Max size' + ] + ]); } /** * Define what happens when the Update operation is loaded. - * + * * @see https://backpackforlaravel.com/docs/crud-operation-update * @return void */ diff --git a/app/Http/Controllers/Admin/DocumentgroupCrudController.php b/app/Http/Controllers/Admin/DocumentgroupCrudController.php index 4b3494f8..8a915fee 100644 --- a/app/Http/Controllers/Admin/DocumentgroupCrudController.php +++ b/app/Http/Controllers/Admin/DocumentgroupCrudController.php @@ -21,7 +21,7 @@ class DocumentgroupCrudController extends CrudController /** * Configure the CrudPanel object. Apply settings to all operations. - * + * * @return void */ public function setup() @@ -33,24 +33,18 @@ public function setup() /** * Define what happens when the List operation is loaded. - * + * * @see https://backpackforlaravel.com/docs/crud-operation-list-entries * @return void */ protected function setupListOperation() { - - - /** - * Columns can be defined using the fluent syntax or array syntax: - * - CRUD::column('price')->type('number'); - * - CRUD::addColumn(['name' => 'price', 'type' => 'number']); - */ + $this->crud->setFromDb(); } /** * Define what happens when the Create operation is loaded. - * + * * @see https://backpackforlaravel.com/docs/crud-operation-create * @return void */ @@ -58,18 +52,48 @@ protected function setupCreateOperation() { CRUD::setValidation(DocumentgroupRequest::class); - - - /** - * Fields can be defined using the fluent syntax or array syntax: - * - CRUD::field('price')->type('number'); - * - CRUD::addField(['name' => 'price', 'type' => 'number'])); - */ + $this->crud->addField([ + [ + 'name' => 'name_ru', + 'type' => 'text', + 'label' => 'Name ru' + ], + [ + 'name' => 'name_en', + 'type' => 'text', + 'label' => 'Name en' + ], + [ + 'name' => 'name_tm', + 'type' => 'text', + 'label' => 'Name tm' + ], + [ + 'name' => 'description_ru', + 'type' => 'textarea', + 'label' => 'Description ru' + ], + [ + 'name' => 'description_en', + 'type' => 'textarea', + 'label' => 'Description en' + ], + [ + 'name' => 'description_tm', + 'type' => 'textarea', + 'label' => 'Description tm' + ], + [ + 'name' => 'type', + 'type' => 'text', + 'label' => 'Type' + ] + ]); } /** * Define what happens when the Update operation is loaded. - * + * * @see https://backpackforlaravel.com/docs/crud-operation-update * @return void */ diff --git a/app/Http/Controllers/Admin/QuestionCrudController.php b/app/Http/Controllers/Admin/QuestionCrudController.php index 886aa3c8..09227df1 100644 --- a/app/Http/Controllers/Admin/QuestionCrudController.php +++ b/app/Http/Controllers/Admin/QuestionCrudController.php @@ -21,7 +21,7 @@ class QuestionCrudController extends CrudController /** * Configure the CrudPanel object. Apply settings to all operations. - * + * * @return void */ public function setup() @@ -33,24 +33,18 @@ public function setup() /** * Define what happens when the List operation is loaded. - * + * * @see https://backpackforlaravel.com/docs/crud-operation-list-entries * @return void */ protected function setupListOperation() { - - - /** - * Columns can be defined using the fluent syntax or array syntax: - * - CRUD::column('price')->type('number'); - * - CRUD::addColumn(['name' => 'price', 'type' => 'number']); - */ + $this->crud->setFromDb(); } /** * Define what happens when the Create operation is loaded. - * + * * @see https://backpackforlaravel.com/docs/crud-operation-create * @return void */ @@ -58,18 +52,23 @@ protected function setupCreateOperation() { CRUD::setValidation(QuestionRequest::class); - - - /** - * Fields can be defined using the fluent syntax or array syntax: - * - CRUD::field('price')->type('number'); - * - CRUD::addField(['name' => 'price', 'type' => 'number'])); - */ + CRUD::addFields([ + [ + 'name' => 'question_text', + 'type' => 'textarea', + 'label' => 'Question text' + ], + [ + 'name' => 'options', + 'type' => 'text', + 'label' => 'Options' + ] + ]); } /** * Define what happens when the Update operation is loaded. - * + * * @see https://backpackforlaravel.com/docs/crud-operation-update * @return void */ diff --git a/app/Http/Controllers/AuthController.php b/app/Http/Controllers/AuthController.php index b95f416b..914deb0a 100644 --- a/app/Http/Controllers/AuthController.php +++ b/app/Http/Controllers/AuthController.php @@ -90,7 +90,7 @@ public function login(Request $request){ $tokenResult = $client->createToken('auth_token'); // return token in json response - return response()->json(['success' => ['token' => $tokenResult]], 200); + return response()->json(['success' => ['token' => $tokenResult, 'client' => $client]], 200); } return response()->json(['error' => ['message' => 'email not found']], 404); } diff --git a/app/Models/Document.php b/app/Models/Document.php index b27691ad..7f06229c 100644 --- a/app/Models/Document.php +++ b/app/Models/Document.php @@ -19,7 +19,15 @@ class Document extends Model // protected $primaryKey = 'id'; // public $timestamps = false; protected $guarded = ['id']; - // protected $fillable = []; + protected $fillable = [ + 'name_ru', + 'name_tm', + 'name_en', + 'description_ru', + 'description_en', + 'description_tm', + 'max_size' + ]; // protected $hidden = []; // protected $dates = []; diff --git a/app/Models/Documentgroup.php b/app/Models/Documentgroup.php index fb86b7e5..05d7572f 100644 --- a/app/Models/Documentgroup.php +++ b/app/Models/Documentgroup.php @@ -19,7 +19,15 @@ class Documentgroup extends Model // protected $primaryKey = 'id'; // public $timestamps = false; protected $guarded = ['id']; - // protected $fillable = []; + protected $fillable = [ + 'name_en', + 'name_ru', + 'name_tm', + 'description_ru', + 'description_tm', + 'description_en', + 'type' + ]; // protected $hidden = []; // protected $dates = []; diff --git a/app/Models/Question.php b/app/Models/Question.php index 5043de39..69f6247d 100644 --- a/app/Models/Question.php +++ b/app/Models/Question.php @@ -19,7 +19,10 @@ class Question extends Model // protected $primaryKey = 'id'; // public $timestamps = false; protected $guarded = ['id']; - // protected $fillable = []; + protected $fillable = [ + 'question_text', + 'options' + ]; // protected $hidden = []; // protected $dates = [];