Dependent Dropdown Ajax with Voyager
Download zip https://github.com/d3turnes/dependent-dropdown-with-voyager/archive/master.zip and decompress the content in your project laravel
Edit the file routes/api.php and add the following code
use Illuminate\Http\Request;
/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/
Route::middleware('auth:api')->get('/user', function (Request $request) {
return $request->user();
});
Route::group(['prefix' => 'v1', 'as' => 'api.v1.', 'namespace' => 'Api\\V1\\'], function() {
Route::post('/dependent-dropdown', ['uses' => 'DependentDropdownController@index', 'as' => 'dropdown']);
});
Edit the file app/Providers/AppServiceProvider.php and add the following code
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use TCG\Voyager\Facades\Voyager;
use App\FormFields\SelectDependentDropdown;
class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
Voyager::addFormField(SelectDependentDropdown::class);
}
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
}
Dependent Dropdown Ajax (Family/Subcategory)
families(id, name, slug)
subcategories(id, name, slug, family_id)
products(id, name, slug, price, dec, subcategory_id, created_at, updated_at)
- move the content of /example1/models to /app
- move the content of /example1/database to /database
- composer dumpautoload
- php artisan migrate
- php artisan db:seed --class=ProductsTableSeeder
Dependent Dropdown Ajax (Country/State/City)
countries(id, name)
states(id, name, country_id)
cities(id, name, state_id)
offices(id, name, slug, address, lat, lng, city_id)
- move the content of /example2/models to /app
- move the content of /example2/database to /database
- composer dumpautoload
- php artisan migrate
- php artisan db:seed --class=CountriesTableSeeder
- php artisan db:seed --class=StatesTableSeeder
- php artisan db:seed --class=CitiesTableSeeder
- php artisan db:seed --class=OfficesTableSeeder