diff --git a/app/Entities/Users/User.php b/app/Entities/Users/User.php index 5330840..c72d6af 100644 --- a/app/Entities/Users/User.php +++ b/app/Entities/Users/User.php @@ -11,7 +11,7 @@ class User extends Authenticatable { use Notifiable, PresentableTrait; - protected $fillable = ['name', 'email', 'password']; + protected $fillable = ['name', 'email', 'password', 'api_token']; protected $hidden = ['password', 'remember_token', 'api_token']; protected $presenter = UserPresenter::class; diff --git a/app/Http/Controllers/AuthController.php b/app/Http/Controllers/AuthController.php index 943bd5f..901a390 100755 --- a/app/Http/Controllers/AuthController.php +++ b/app/Http/Controllers/AuthController.php @@ -27,6 +27,8 @@ class AuthController extends Controller { $registerData = $request->only('name', 'email', 'password'); + $registerData['api_token'] = str_random(32); + $user = User::create($registerData); $user->assignRole('admin'); $user->assignRole('worker'); diff --git a/app/Http/Requests/Subscriptions/CreateRequest.php b/app/Http/Requests/Subscriptions/CreateRequest.php index 2b31e34..db4fa61 100644 --- a/app/Http/Requests/Subscriptions/CreateRequest.php +++ b/app/Http/Requests/Subscriptions/CreateRequest.php @@ -4,37 +4,39 @@ namespace App\Http\Requests\Subscriptions; use App\Http\Requests\Request; -class CreateRequest extends Request { +class CreateRequest extends Request +{ - /** - * Determine if the user is authorized to make this request. - * - * @return bool - */ - public function authorize() - { - return auth()->user()->can('manage_subscriptions'); - } + /** + * Determine if the user is authorized to make this request. + * + * @return bool + */ + public function authorize() + { + return auth()->user()->can('manage_subscriptions'); + } - /** - * Get the validation rules that apply to the request. - * - * @return array - */ - public function rules() - { - return [ - 'domain_name' => 'required|max:60|unique:subscriptions,domain_name', - 'epp_code' => 'max:60', - 'domain_price' => 'required|numeric', - 'hosting_capacity' => 'max:60', - 'hosting_price' => 'required_with:hosting_capacity|numeric', - 'start_date' => 'required|date|date_format:Y-m-d', - 'due_date' => 'required|date|date_format:Y-m-d', - 'customer_id' => 'required|numeric', - 'project_id' => 'required|numeric', - 'remark' => 'max:255', - ]; - } + /** + * Get the validation rules that apply to the request. + * + * @return array + */ + public function rules() + { + return [ + 'domain_name' => 'required|max:60|unique:subscriptions,domain_name', + 'epp_code' => 'max:60', + 'domain_price' => 'required|numeric', + 'hosting_capacity' => 'max:60', + 'hosting_price' => 'required_with:hosting_capacity|numeric', + 'start_date' => 'required|date|date_format:Y-m-d', + 'due_date' => 'required|date|date_format:Y-m-d', + 'customer_id' => 'required|numeric', + 'project_id' => 'required|numeric', + 'vendor_id' => 'required|numeric', + 'remark' => 'max:255', + ]; + } } diff --git a/app/Http/Requests/Subscriptions/UpdateRequest.php b/app/Http/Requests/Subscriptions/UpdateRequest.php index 058d5bd..20d5ee6 100644 --- a/app/Http/Requests/Subscriptions/UpdateRequest.php +++ b/app/Http/Requests/Subscriptions/UpdateRequest.php @@ -4,37 +4,39 @@ namespace App\Http\Requests\Subscriptions; use App\Http\Requests\Request; -class UpdateRequest extends Request { +class UpdateRequest extends Request +{ - /** - * Determine if the user is authorized to make this request. - * - * @return bool - */ - public function authorize() - { - return auth()->user()->can('manage_subscriptions'); - } + /** + * Determine if the user is authorized to make this request. + * + * @return bool + */ + public function authorize() + { + return auth()->user()->can('manage_subscriptions'); + } - /** - * Get the validation rules that apply to the request. - * - * @return array - */ - public function rules() - { - return [ - 'domain_name' => 'required|max:60|unique:subscriptions,domain_name,' . $this->segment(2), - 'epp_code' => 'max:60', - 'domain_price' => 'required|numeric', - 'hosting_capacity' => 'max:60', - 'hosting_price' => 'required_with:hosting_capacity|numeric', - 'start_date' => 'required|date|date_format:Y-m-d', - 'due_date' => 'required|date|date_format:Y-m-d', - 'customer_id' => 'required|numeric', - 'project_id' => 'required|numeric', - 'remark' => 'max:255', - ]; - } + /** + * Get the validation rules that apply to the request. + * + * @return array + */ + public function rules() + { + return [ + 'domain_name' => 'required|max:60|unique:subscriptions,domain_name,'.$this->segment(2), + 'epp_code' => 'max:60', + 'domain_price' => 'required|numeric', + 'hosting_capacity' => 'max:60', + 'hosting_price' => 'required_with:hosting_capacity|numeric', + 'start_date' => 'required|date|date_format:Y-m-d', + 'due_date' => 'required|date|date_format:Y-m-d', + 'customer_id' => 'required|numeric', + 'project_id' => 'required|numeric', + 'vendor_id' => 'required|numeric', + 'remark' => 'max:255', + ]; + } } diff --git a/database/factories/ModelFactory.php b/database/factories/ModelFactory.php index b65530d..ae8f2fb 100644 --- a/database/factories/ModelFactory.php +++ b/database/factories/ModelFactory.php @@ -15,7 +15,7 @@ $factory->define(User::class, function (Faker\Generator $faker) { 'email' => $faker->unique()->email, 'password' => 'member', 'remember_token' => str_random(10), - 'api_token' => str_random(40), + 'api_token' => str_random(32), ]; });