php - Laravel 5.2 route with optional parameters not working -


i can't seem find problem, hope can me.

im trying reach controller, , use parameter, alwasy says missing parameter.

route file:

route::get('admin/site-settings/global-data/{part?}/', ['as' => 'admin/global-data-edit', 'uses' => 'admin\globaldatascontroller@getglobaldata']); 

function:

    public function getglobaldata(request $request, $part){      $globaldata = globaldata::find(1);      switch ($part){          case "content":              if($request->ajax()){                 return view('admin.site-settings.global-data._ajax_load_content', compact('globaldata'));             }              return view('admin.site-settings.global-data.edit')->with('globaldata', $globaldata);              break;          case "logo":              if($request->ajax()){                 return view('admin.site-settings.global-data._ajax_load_logo', compact('globaldata'));             }              return view('admin.site-settings.global-data.edit')->with('globaldata', $globaldata);              break;     }   } 

and view:

        function load_data() {         $('#load-data').hide().html('<div class="loader"><i class="fa fa-spinner" aria-hidden="true"></i></div>').fadein();         var url = '{{route('admin/global-data-edit')}}';         $.ajax({             url: url,             type: "get",             success: function(data){                 $data = $(data);                 $('#load-data').hide().html($data).fadein();             }         });     } 

thank muych time in advance!

best regards.

change:

public function getglobaldata(request $request, $part){ 

to:

public function getglobaldata(request $request, $part = null){ 

Comments

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

serialization - Convert Any type in scala to Array[Byte] and back -

SonarQube Plugin for Jenkins does not find SonarQube Scanner executable -