From 37c847ea08a7c8043ad5893bf791249fd6124fe3 Mon Sep 17 00:00:00 2001 From: snipe Date: Wed, 14 Dec 2016 09:56:23 -0800 Subject: [PATCH] Clearer/updated/named custom fields routes This is still broken --- .../Controllers/CustomFieldsController.php | 17 +++---- resources/views/custom_fields/index.blade.php | 4 +- resources/views/custom_fields/show.blade.php | 5 ++- routes/web.php | 44 ++++++++++++++++--- 4 files changed, 51 insertions(+), 19 deletions(-) diff --git a/app/Http/Controllers/CustomFieldsController.php b/app/Http/Controllers/CustomFieldsController.php index 19099beccf..245ce50d50 100644 --- a/app/Http/Controllers/CustomFieldsController.php +++ b/app/Http/Controllers/CustomFieldsController.php @@ -33,13 +33,11 @@ class CustomFieldsController extends Controller * @since [v1.8] * @return View */ - public function index() + public function getIndex() { - // - $fieldsets=CustomFieldset::with("fields", "models")->get(); - //$fieldsets=CustomFieldset::all(); - $fields=CustomField::with("fieldset")->get(); - //$fields=CustomField::all(); + + $fieldsets = CustomFieldset::with("fields", "models")->get(); + $fields = CustomField::with("fieldset")->get(); return View::make("custom_fields.index")->with("custom_fieldsets", $fieldsets)->with("custom_fields", $fields); } @@ -53,7 +51,6 @@ class CustomFieldsController extends Controller */ public function create() { - // return View::make("custom_fields.create"); } @@ -74,7 +71,7 @@ class CustomFieldsController extends Controller "user_id" => Auth::user()->id] ); - $validator=Validator::make(Input::all(), $cfset->rules); + $validator = Validator::make(Input::all(), $cfset->rules); if ($validator->passes()) { $cfset->save(); return redirect()->route("admin.custom_fields.show", [$cfset->id])->with('success', trans('admin/custom_fields/message.fieldset.create.success')); @@ -209,10 +206,10 @@ class CustomFieldsController extends Controller * @since [v1.8] * @return View */ - public function show($id) + public function getCustomFieldset($id) { $cfset = CustomFieldset::with('fields')->where('id','=',$id)->orderBy('id','ASC')->first(); - $custom_fields_list = ["" => "Add New Field to Fieldset"] + CustomField::lists("name", "id")->toArray(); + $custom_fields_list = ["" => "Add New Field to Fieldset"] + CustomField::pluck("name", "id")->toArray(); $maxid = 0; foreach ($cfset->fields() as $field) { diff --git a/resources/views/custom_fields/index.blade.php b/resources/views/custom_fields/index.blade.php index c266f15c82..7f9e4109c1 100644 --- a/resources/views/custom_fields/index.blade.php +++ b/resources/views/custom_fields/index.blade.php @@ -17,7 +17,7 @@

{{ trans('admin/custom_fields/general.fieldsets') }}

@@ -50,7 +50,7 @@ @endforeach - {{ Form::open(array('route' => array('admin.custom_fields.destroy', $fieldset->id), 'method' => 'delete')) }} + {{ Form::open(array('route' => array('admin.custom_fields.delete-field', $fieldset->id), 'method' => 'delete')) }} @if($fieldset->models->count() > 0) diff --git a/resources/views/custom_fields/show.blade.php b/resources/views/custom_fields/show.blade.php index 082ff02ad0..507ebfebe6 100644 --- a/resources/views/custom_fields/show.blade.php +++ b/resources/views/custom_fields/show.blade.php @@ -48,7 +48,10 @@ - {{ Form::open(['route' => ["admin.custom_fields.associate",$custom_fieldset->id], 'class'=>'form-horizontal', 'id' => 'ordering']) }} + {{ Form::open(['route' => + ["admin.custom_fields.associate",$custom_fieldset->id], + 'class'=>'form-horizontal', + 'id' => 'ordering']) }} {{ Form::checkbox("required","on") }} {{ trans('admin/custom_fields/general.required') }} {{ Form::text("order",$maxid)}} diff --git a/routes/web.php b/routes/web.php index e17be441ae..8e622abfaf 100644 --- a/routes/web.php +++ b/routes/web.php @@ -797,13 +797,45 @@ Route::group([ 'prefix' => 'admin','middleware' => ['web','auth']], function () }); # Custom fields support - Route::get('custom_fields/create-field', ['uses' =>'CustomFieldsController@createField','as' => 'admin.custom_fields.create-field']); - Route::post('custom_fields/create-field', ['uses' => 'CustomFieldsController@storeField','as' => 'admin.custom_fields.store-field']); - Route::post('custom_fields/{id}/associate', ['uses' => 'CustomFieldsController@associate','as' => 'admin.custom_fields.associate']); - Route::get('custom_fields/{field_id}/{fieldset_id}/disassociate', ['uses' => 'CustomFieldsController@deleteFieldFromFieldset','as' => 'admin.custom_fields.disassociate']); - Route::match(['DELETE'], 'custom_fields/delete-field/{id}', ['uses' => 'CustomFieldsController@deleteField','as' => 'admin.custom_fields.delete-field']); + Route::get('customfields/field/create', + ['uses' =>'CustomFieldsController@createField', + 'as' => 'admin.custom_fields.create-field'] + ); - Route::get('custom_fields', ['uses' =>'CustomFieldsController@index','as' => 'admin.custom_fields.index']); + Route::get('customfields/fieldset/create', + ['as' => 'admin.custom_fields.create-fieldset', + 'uses' => 'CustomFieldsController@create'] + ); + + Route::post('customfields/field/create', + ['uses' => 'CustomFieldsController@storeField', + 'as' => 'admin.custom_fields.store-field'] + ); + + Route::post('customfields/field/{id}/associate', + ['uses' => 'CustomFieldsController@associate', + ' as' => 'admin.custom_fields.associate'] + ); + + Route::get('customfields/fieldset/{fieldset_id}/{field_id}/disassociate', + ['uses' => 'CustomFieldsController@deleteFieldFromFieldset', + 'as' => 'admin.custom_fields.disassociate'] + ); + + Route::get('custom_fields/field/{id}/delete', + ['uses' =>'CustomFieldsController@deleteField', + 'as' => 'admin.custom_fields.delete-field'] + ); + + Route::get('customfields/fieldset/{id}/view', + ['uses' =>'CustomFieldsController@getCustomFieldset', + 'as' => 'admin.custom_fields.show'] + ); + + Route::get('customfields', + ['uses' =>'CustomFieldsController@getIndex', + 'as' => 'admin.custom_fields.index'] + ); # User Management