From 4222dc640c4c4e2a8b34579d9af0529c7bcb0d7c Mon Sep 17 00:00:00 2001 From: CheeSiong Date: Fri, 23 Oct 2020 13:08:25 +0800 Subject: [PATCH] pull --- app/Models/Address.php | 39 ++++++++++++++++++++++++------- database/seeds/DatabaseSeeder.php | 10 +++++++- routes/account.php | 27 ++++++++++----------- routes/api.php | 1 + 4 files changed, 54 insertions(+), 23 deletions(-) diff --git a/app/Models/Address.php b/app/Models/Address.php index 2873ae8f..78033755 100644 --- a/app/Models/Address.php +++ b/app/Models/Address.php @@ -5,31 +5,37 @@ namespace App\Models; use Illuminate\Database\Eloquent\Relations\HasOne; use Illuminate\Database\Eloquent\SoftDeletes; - /** * Class Address * @package App\Models * @version August 4, 2020, 4:36 am * - * @property \App\Models\Company company + * @property \App\Models\Country country_id + * @property \App\Models\Company company_id + * @property \App\Models\State state_id + * @property \App\Models\District district_id + * @property string postcode * @property string street_one * @property string street_two - * @property string city - * @property string state - * @property string post_code - * @property string country + * @property integer billing_type */ class Address extends AbstractModel { - use SoftDeletes; - protected $table = 'addresses'; protected $dates = ['deleted_at']; - /** + /** + * @return \Illuminate\Database\Eloquent\Relations\HasOne + **/ + public function country(): HasOne + { + return $this->hasOne(Country::class, 'country_id', 'id'); + } + + /** * @return \Illuminate\Database\Eloquent\Relations\HasOne **/ public function company(): HasOne @@ -37,4 +43,19 @@ class Address extends AbstractModel return $this->hasOne(Company::class, 'company_id', 'id'); } + /** + * @return \Illuminate\Database\Eloquent\Relations\HasOne + **/ + public function state(): HasOne + { + return $this->hasOne(State::class, 'state_id', 'id'); + } + + /** + * @return \Illuminate\Database\Eloquent\Relations\HasOne + **/ + public function district(): HasOne + { + return $this->hasOne(District::class, 'district_id', 'id'); + } } diff --git a/database/seeds/DatabaseSeeder.php b/database/seeds/DatabaseSeeder.php index b7bb377b..b02b426f 100644 --- a/database/seeds/DatabaseSeeder.php +++ b/database/seeds/DatabaseSeeder.php @@ -11,6 +11,14 @@ class DatabaseSeeder extends Seeder */ public function run() { - // + DB::beginTransaction(); + + //General + $this->call(CountriesTableSeeder::class); + $this->call(CurrenciesTableSeeder::class); + $this->call(StatesTableSeeder::class); + $this->call(DistrictsTableSeeder::class); + + DB::commit(); } } diff --git a/routes/account.php b/routes/account.php index 91c59336..eff6dd7b 100644 --- a/routes/account.php +++ b/routes/account.php @@ -2,26 +2,27 @@ use Illuminate\Support\Facades\Route; -Route::group(['prefix' => 'account', 'namespace' => 'Account', 'as' => 'account.'], function () { +Route::group(['prefix' => 'account', 'namespace' => 'Accounts', 'as' => 'account.'], function () { Route::group(['prefix' => 'authentication', 'as' => 'authentication.'], function () { - Route::group(['prefix' => 'login', 'as' => 'authenticate.'], function () { - Route::post('/attempt', 'UserAuthenticationController@authenticate')->name('attempt'); - Route::post('/check_email', 'CheckEmailController@check')->name('email.check'); - }); + // Route::group(['prefix' => 'login', 'as' => 'authenticate.'], function () { + // Route::post('/attempt', 'UserAuthenticationController@authenticate')->name('attempt'); + // Route::post('/check_email', 'CheckEmailController@check')->name('email.check'); + // }); - Route::group(['prefix' => 'password', 'as' => 'password.'], function () { - Route::post('/forget', 'GeneratePasswordResetController@generate')->name('forget'); - Route::post('/reset', 'ResetPasswordController@reset')->name('reset'); - }); + // Route::group(['prefix' => 'password', 'as' => 'password.'], function () { + // Route::post('/forget', 'GeneratePasswordResetController@generate')->name('forget'); + // Route::post('/reset', 'ResetPasswordController@reset')->name('reset'); + // }); - Route::post('/registration', 'CreateUserController@create')->name('registration'); }); - Route::group(['prefix' => 'user', 'as' => 'user.'], function () { - Route::get('list', 'ListUsersController@list')->name('list'); - }); + Route::post('/registration', 'CreateUserController@create')->name('registration'); + + // Route::group(['prefix' => 'user', 'as' => 'user.'], function () { + // Route::get('list', 'ListUsersController@list')->name('list'); + // }); }); \ No newline at end of file diff --git a/routes/api.php b/routes/api.php index a06dbd3f..343abddc 100644 --- a/routes/api.php +++ b/routes/api.php @@ -15,6 +15,7 @@ use Illuminate\Support\Facades\Route; */ Route::group(['middleware' => 'api', 'prefix' => 'v1', 'as' => 'api.'], function () { + require __DIR__ . '/account.php'; Route::group(['middleware' => 'valid.token'], function () {