https://github.com/d3turnes/dependent-dropdown-with-voyager
Dependent Dropdown with Voyager
https://github.com/d3turnes/dependent-dropdown-with-voyager
dependent-dropdown-ajax voyager voyager-formfields
Last synced: 5 months ago
JSON representation
Dependent Dropdown with Voyager
- Host: GitHub
- URL: https://github.com/d3turnes/dependent-dropdown-with-voyager
- Owner: d3turnes
- Created: 2019-08-27T01:57:29.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2019-08-28T17:55:34.000Z (about 6 years ago)
- Last Synced: 2025-03-31T09:11:11.629Z (6 months ago)
- Topics: dependent-dropdown-ajax, voyager, voyager-formfields
- Language: PHP
- Size: 190 KB
- Stars: 11
- Watchers: 2
- Forks: 6
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# dependent-dropdown-with-voyager
Dependent Dropdown Ajax with Voyager
# Install
Download zip https://github.com/d3turnes/dependent-dropdown-with-voyager/archive/master.zip and decompress the content in your project laravelEdit the file routes/api.php and add the following code
```php
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
```php
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()
{
//
}
}```
# Example 1
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 /database1. composer dumpautoload
2. php artisan migrate
3. php artisan db:seed --class=ProductsTableSeeder
* Definition
# Example 2
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 /database1. composer dumpautoload
2. php artisan migrate
3. php artisan db:seed --class=CountriesTableSeeder
3. php artisan db:seed --class=StatesTableSeeder
3. php artisan db:seed --class=CitiesTableSeeder
3. php artisan db:seed --class=OfficesTableSeeder
* Definition
