create user from account preview finished

This commit is contained in:
Mahri Ilmedova 2022-10-07 13:56:38 +05:00
parent 4e674526cd
commit 1c383da7db
4 changed files with 99 additions and 0 deletions

View File

@ -10,6 +10,7 @@
use App\Http\Resources\QuestionResource;
use App\Models\Account;
use App\Models\Application;
use App\Models\Client;
use App\Models\Question;
use Illuminate\Http\Request;
@ -59,5 +60,19 @@ public function approveApplication(Request $request){
return redirect()->back();
}
public function createAccountClient($account_id){
return view('admin.account_client_create',[
'account_id' => $account_id
]);
}
public function createClient(Request $request){
$data = $request->only('firstname', 'lastname', 'email', 'password', 'account_id');
$data['is_verified'] = false;
$data['is_suspended'] = false;
$client = new Client($data);
$client->save();
return redirect()->to('/admin/preview/' . $request->account_id . '#users');
}
}

View File

@ -0,0 +1,77 @@
@extends(backpack_view('blank'))
@section('content')
<nav aria-label="breadcrumb" class="d-none d-lg-block">
<ol class="breadcrumb m-0 mb-3">
<li class="breadcrumb-item"><a href="/admin">Admin</a></li>
<li class="breadcrumb-item"><a href="/admin/account">Account</a></li>
<li class="breadcrumb-item"><a href="#">Add Client</a></li>
</ol>
</nav>
<div class="row">
<div class="col-md-8 bold-labels">
<!-- Default box -->
<form method="post" action="/admin/client/custom-create">
@csrf
<div class="card">
<div class="card-body row">
<!-- text input -->
<input type="hidden" name="account_id" value="{{ $account_id }}">
<div class="form-group col-sm-12" element="div" bp-field-wrapper="true" bp-field-name="firstname"
bp-field-type="text">
<label>Firstname</label>
<input type="text" name="firstname" value="" class="form-control">
</div> <!-- text input -->
<div class="form-group col-sm-12" element="div" bp-field-wrapper="true" bp-field-name="lastname"
bp-field-type="text">
<label>Lastname</label>
<input type="text" name="lastname" value="" class="form-control">
</div> <!-- text input -->
<div class="form-group col-sm-12" element="div" bp-field-wrapper="true" bp-field-name="email"
bp-field-type="email">
<label>Email</label>
<input type="email" name="email" value="" class="form-control">
</div>
<div class="form-group col-sm-12" element="div" bp-field-wrapper="true" bp-field-name="email"
bp-field-type="email">
<label>Password</label>
<input type="text" name="password" value="" class="form-control">
</div>
</div>
</div>
<!-- This makes sure that all field assets are loaded. -->
<div class="d-none" id="parentLoadedAssets">["bpFieldInitCheckbox"]</div>
<div id="saveActions" class="form-group">
<input type="hidden" name="_save_action" value="save_and_back">
<div class="btn-group" role="group">
<button type="submit" class="btn btn-success">
<span class="la la-save" role="presentation" aria-hidden="true"></span> &nbsp;
<span data-value="save_and_back">Save and back</span>
</button>
</div>
</div>
</form>
</div>
</div>
@endsection

View File

@ -186,6 +186,11 @@
</table>
</div>
<div class="tab-pane" id="users" role="tabpanel">
<div class="mb-3">
<a href="/admin/create-account-client/{{ $account->id }}" class="btn btn-primary">
Add new user
</a>
</div>
<table class="table table-responsive-sm table-striped mb-0">
<thead class="thead-light">
<tr>

View File

@ -44,5 +44,7 @@
Route::post('/approve-application/{id}', [ResourceController::class, 'approveApplication']);
Route::get('/export-account-admin/{id}', [ExportController::class, 'export']);
Route::post('/create-application-ticket', [TicketController::class, 'createAppTicket']);
Route::get('/create-account-client/{id}', [ResourceController::class, 'createAccountClient']);
Route::post('/client/custom-create', [ResourceController::class, 'createClient']);
}); // this should be the absolute last line of this file