From: Vincent Vanwaelscappel Date: Wed, 17 Apr 2024 16:43:16 +0000 (+0200) Subject: wip #6867 @2 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=2c0fcbba1bf72ccdb68f9509c40e33ae891f72fa;p=bastide-resah.git wip #6867 @2 --- diff --git a/app/Http/Controllers/Admin/ClientCrudController.php b/app/Http/Controllers/Admin/ClientCrudController.php new file mode 100644 index 0000000..1376ba9 --- /dev/null +++ b/app/Http/Controllers/Admin/ClientCrudController.php @@ -0,0 +1,30 @@ +withoutMiddleware([CheckIfAdmin::class, VerifyCsrfToken::class]); + Route::match(['post'], $segment . '/login', $controller . '@login')->withoutMiddleware([CheckIfAdmin::class, VerifyCsrfToken::class]); + Route::match(['post'], $segment . '/forgotpassword', $controller . '@login')->withoutMiddleware([CheckIfAdmin::class, VerifyCsrfToken::class]); + } + + protected function signin() + { + $validator = Validator::make(request()->all(), [ + 'finess' => 'required|regex:/^[0-9]{9}$/', + 'password' => 'required|confirmed|min:8', + 'hospital' => 'required', + 'firstname' => 'required', + 'name' => 'required', + 'function' => 'required', + 'phone' => 'required|regex:/^0[0-9]{9}$/', + 'email' => 'required|confirmed|unique:App\Models\Client,email', + ]); + + if ($validator->fails()) { + return response()->setStatusCode(422)->json(['errors' => $validator->errors()]); + } else { + + $client = new Client(); + foreach ($validator->valid() as $k => $v) { + if ($k === 'password') { + $client->$k = Hash::make($v); + } else { + $client->$k = $v; + } + } + $client->enabled = false; + $client->save(); + + return response()->setStatusCode(200)->json(['success' => 'ok']); + + } + } + + protected function login() + { +// + } + + protected function forgotpassword() + { + // + } +} diff --git a/app/Models/Client.php b/app/Models/Client.php index 271751d..12d466f 100644 --- a/app/Models/Client.php +++ b/app/Models/Client.php @@ -2,6 +2,7 @@ namespace App\Models; +use App\Http\Controllers\Operations\Client\Fluidbook; use Cubist\Backpack\Magic\Fields\Text; use Cubist\Backpack\Magic\Models\CubistMagicAuthenticatable; @@ -12,6 +13,7 @@ class Client extends CubistMagicAuthenticatable 'singular' => 'client', 'plural' => 'clients']; + protected $_operations = [Fluidbook::class]; public function setFields() {