Commit b5a28bf9 authored by Viral Solani's avatar Viral Solani

Remove City, State and Countries

parent c8ae33a0
......@@ -6,8 +6,6 @@ use App\Http\Controllers\Controller;
use App\Models\Access\Permission\Permission;
use App\Models\Access\Role\Role;
use App\Models\Access\User\User;
use App\Models\Cities\City;
use App\Models\States\State;
use Illuminate\Http\Request;
/**
......@@ -23,40 +21,6 @@ class DashboardController extends Controller
return view('backend.dashboard');
}
/**
* Used to get the states of default country.
*
* @param Request $request
*
* @return JSON
*/
public function getStates(Request $request)
{
$states = State::where('country_id', config('access.constants.default_country'))->pluck('state', 'id')->toArray();
return [
'status' => 'state',
'data' => $states,
];
}
/**
* Used to get the cities of selected state.
*
* @param Request $request
*
* @return JSON
*/
public function getCities(Request $request)
{
$cities = City::where('state_id', $request->stateId)->pluck('city', 'id')->toArray();
return [
'status' => 'city',
'data' => $cities,
];
}
/**
* Used to display form for edit profile.
*
......
......@@ -3,9 +3,7 @@
namespace App\Http\Controllers\Frontend;
use App\Http\Controllers\Controller;
use App\Models\Cities\City;
use App\Models\Settings\Setting;
use App\Models\States\State;
use App\Repositories\Frontend\CMSPages\CMSPagesRepository;
use Illuminate\Http\Request;
......@@ -33,42 +31,6 @@ class FrontendController extends Controller
return view('frontend.macros');
}
/**
* Used to get the states of default country.
*
* @param Request $request
*
* @return JSON
*/
public function getStates(Request $request)
{
$states = State::where('country_id', config('access.constants.default_country'))
->pluck('state', 'id')->toArray();
return [
'status' => 'state',
'data' => $states,
];
}
/**
* Used to get the cities of selected state.
*
* @param Request $request
*
* @return JSON
*/
public function getCities(Request $request)
{
$cities = City::where('state_id', $request->stateId)->pluck('city', 'id')
->toArray();
return [
'status' => 'city',
'data' => $cities,
];
}
/**
* show cmspage by pageslug.
*/
......
......@@ -3,9 +3,6 @@
namespace App\Models\Access\User\Traits\Relationship;
use App\Models\Access\User\SocialLogin;
use App\Models\Cities\City;
use App\Models\Countries\Country;
use App\Models\States\State;
use App\Models\System\Session;
/**
......@@ -49,34 +46,4 @@ trait UserRelationship
{
return $this->hasMany(Session::class);
}
/**
* Has-One relationship with state.
*
* @return mixed
*/
public function state()
{
return $this->hasOne(State::class, 'id', 'state_id');
}
/**
* Has-One relationship with cty.
*
* @return mixed
*/
public function city()
{
return $this->hasOne(City::class, 'id', 'city_id');
}
/**
* Has-One relationship with country.
*
* @return mixed
*/
public function country()
{
return $this->hasOne(Country::class, 'id', 'country_id');
}
}
<?php
namespace App\Models\Cities;
use App\Models\BaseModel;
use App\Models\Cities\Traits\Relationship\CityRelationship;
class City extends BaseModel
{
use CityRelationship;
/**
* The database table used by the model.
*
* @var string
*/
protected $table;
public function __construct()
{
$this->table = config('access.cities_table');
}
}
<?php
namespace App\Models\Cities\Traits\Relationship;
use App\Models\States\State;
/**
* Class CityRelationship.
*/
trait CityRelationship
{
/**
* Cities belongs to relationship with state.
*/
public function state()
{
return $this->belongsTo(State::class);
}
}
<?php
namespace App\Models\Countries;
use App\Models\BaseModel;
class Country extends BaseModel
{
/**
* The database table used by the model.
*
* @var string
*/
protected $table;
public function __construct()
{
$this->table = config('access.countries_table');
}
}
<?php
namespace App\Models\States;
use App\Models\BaseModel;
use App\Models\States\Traits\Relationship\StateRelationship;
class State extends BaseModel
{
use StateRelationship;
/**
* The database table used by the model.
*
* @var string
*/
protected $table;
public function __construct()
{
$this->table = config('access.states_table');
}
}
<?php
namespace App\Models\States\Traits\Relationship;
use App\Models\Cities\City;
use App\Models\Countries\Country;
/**
* Class StateRelationship.
*/
trait StateRelationship
{
/**
* States belongs to relationship with country.
*/
public function country()
{
return $this->bolongsTo(Country::class);
}
/**
* States has many relationship with cities.
*/
public function cities()
{
return $this->hasMany(City::class);
}
}
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateCitiesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('cities', function (Blueprint $table) {
$table->increments('id');
$table->integer('state_id')->unsigned()->index();
$table->string('city', 191);
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('cities');
}
}
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateCountriesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('countries', function (Blueprint $table) {
$table->increments('id');
$table->string('country', 191);
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('countries');
}
}
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateStatesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('states', function (Blueprint $table) {
$table->increments('id');
$table->integer('country_id')->unsigned()->index();
$table->string('state', 191);
$table->string('state_code', 191);
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('states');
}
}
......@@ -4,8 +4,6 @@
* All route names are prefixed with 'admin.'.
*/
Route::get('dashboard', 'DashboardController@index')->name('dashboard');
Route::post('/get/states', 'DashboardController@getStates')->name('get.states');
Route::post('/get/cities', 'DashboardController@getCities')->name('get.cities');
Route::post('get-permission', 'DashboardController@getPermissionByRole')->name('get.permission');
/*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment