Add Notes to Users (#1406)

* Fix migration

Add Notes

* Migration to add mediumtext field
* Model update
* Admin blade update

* Hide notes by default

* Fix fields layout
This commit is contained in:
B.Fatih KOZ 2022-02-11 23:58:16 +03:00 committed by GitHub
parent 9e080d544a
commit 607ea6f5e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 24 deletions

View File

@ -0,0 +1,15 @@
<?php
use App\Contracts\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class UpdateUsersAddNotes extends Migration
{
public function up()
{
Schema::table('users', function (Blueprint $table) {
$table->mediumText('notes')->nullable()->after('remember_token');
});
}
}

View File

@ -88,6 +88,7 @@ class User extends Authenticatable
'toc_accepted', 'toc_accepted',
'opt_in', 'opt_in',
'last_ip', 'last_ip',
'notes',
'created_at', 'created_at',
'updated_at', 'updated_at',
]; ];
@ -104,6 +105,7 @@ class User extends Authenticatable
'password', 'password',
'last_ip', 'last_ip',
'remember_token', 'remember_token',
'notes',
]; ];
protected $casts = [ protected $casts = [

View File

@ -5,19 +5,16 @@
{{ Form::number('pilot_id', null, ['class' => 'form-control']) }} {{ Form::number('pilot_id', null, ['class' => 'form-control']) }}
<p class="text-danger">{{ $errors->first('pilot_id') }}</p> <p class="text-danger">{{ $errors->first('pilot_id') }}</p>
</div> </div>
<div class="form-group col-sm-3"> <div class="form-group col-sm-3">
{{ Form::label('name', 'Name:') }} {{ Form::label('name', 'Name:') }}
{{ Form::text('name', null, ['class' => 'form-control', 'autocomplete' => 'off']) }} {{ Form::text('name', null, ['class' => 'form-control', 'autocomplete' => 'off']) }}
<p class="text-danger">{{ $errors->first('name') }}</p> <p class="text-danger">{{ $errors->first('name') }}</p>
</div> </div>
<div class="form-group col-sm-3"> <div class="form-group col-sm-3">
{{ Form::label('email', 'Email:') }} {{ Form::label('email', 'Email:') }}
{{ Form::text('email', null, ['class' => 'form-control', 'autocomplete' => 'off']) }} {{ Form::text('email', null, ['class' => 'form-control', 'autocomplete' => 'off']) }}
<p class="text-danger">{{ $errors->first('email') }}</p> <p class="text-danger">{{ $errors->first('email') }}</p>
</div> </div>
<div class="form-group col-sm-3"> <div class="form-group col-sm-3">
{{ Form::label('password', 'Password:') }} {{ Form::label('password', 'Password:') }}
{{ Form::password('password', ['class' => 'form-control', 'autocomplete' => 'off']) }} {{ Form::password('password', ['class' => 'form-control', 'autocomplete' => 'off']) }}
@ -52,7 +49,6 @@
{{ Form::select('curr_airport_id', $airports, null , ['class' => 'form-control select2']) }} {{ Form::select('curr_airport_id', $airports, null , ['class' => 'form-control select2']) }}
<p class="text-danger">{{ $errors->first('curr_airport_id') }}</p> <p class="text-danger">{{ $errors->first('curr_airport_id') }}</p>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
@ -60,12 +56,10 @@
{{ Form::label('airline_id', 'Airline:') }} {{ Form::label('airline_id', 'Airline:') }}
{{ Form::select('airline_id', $airlines, null, ['class' => 'form-control select2', 'placeholder' => 'Select Airline']) }} {{ Form::select('airline_id', $airlines, null, ['class' => 'form-control select2', 'placeholder' => 'Select Airline']) }}
</div> </div>
<div class="form-group col-sm-4"> <div class="form-group col-sm-4">
{{ Form::label('rank_id', 'Rank:') }} {{ Form::label('rank_id', 'Rank:') }}
{{ Form::select('rank_id', $ranks, null, ['class' => 'form-control select2', 'placeholder' => 'Select Rank']) }} {{ Form::select('rank_id', $ranks, null, ['class' => 'form-control select2', 'placeholder' => 'Select Rank']) }}
</div> </div>
<div class="form-group col-sm-4"> <div class="form-group col-sm-4">
{{ Form::label('roles', 'Roles:') }} {{ Form::label('roles', 'Roles:') }}
{{ Form::select('roles[]', $roles, $user->roles->pluck('id'), {{ Form::select('roles[]', $roles, $user->roles->pluck('id'),
@ -74,17 +68,21 @@
</div> </div>
<div class="row"> <div class="row">
<div class="form-group col-sm-6"> <div class="form-group col-md-4">
{{ Form::label('state', 'State:') }} {{ Form::label('state', 'State:') }}
<label class="checkbox-inline"> {{-- <label class="checkbox-inline"> --}}
{{ Form::select('state', UserState::labels(), null, ['class' => 'form-control select2']) }} {{ Form::select('state', UserState::labels(), null, ['class' => 'form-control select2', 'style' => 'width: 100%;']) }}
</label> {{-- </label> --}}
</div> </div>
<div class="form-group col-md-8">
{{ Form::label('notes', 'Management Notes:') }}
{{ Form::textarea('notes', null, ['class' => 'form-control', 'rows' => 4, 'autocomplete' => 'off']) }}
</div>
</div>
<!-- Submit Field --> <div class="row">
<div class="form-group col-sm-6 text-right"> <div class="form-group col-sm-12 text-right">
{{--<a href="{{ route('admin.users.regen_apikey', [$user->id]) }}" class="btn btn-warning" {{-- <a href="{{ route('admin.users.regen_apikey', [$user->id]) }}" class="btn btn-warning" onclick="return confirm('Are you sure? This will reset this user\'s API key.')">New API Key</a> --}}
onclick="return confirm('Are you sure? This will reset this user\'s API key.')">new api key</a>--}}
&nbsp; &nbsp;
{{ Form::button('Save', ['type' => 'submit', 'class' => 'btn btn-success']) }} {{ Form::button('Save', ['type' => 'submit', 'class' => 'btn btn-success']) }}
<a href="{{ route('admin.users.index') }}" class="btn btn-default">Cancel</a> <a href="{{ route('admin.users.index') }}" class="btn btn-default">Cancel</a>
@ -95,10 +93,8 @@
<div class="form-group col-sm-12"> <div class="form-group col-sm-12">
<table class="table table-hover"> <table class="table table-hover">
<tr> <tr>
<td colspan="2"> <td colspan="2"><h5>User Details</h5></td>
<h5>User Details</h5> </tr>
</td>
</tr>
<tr> <tr>
<td>Total Flights</td> <td>Total Flights</td>
<td>{{ $user->flights }}</td> <td>{{ $user->flights }}</td>
@ -127,14 +123,10 @@
<td>@lang('profile.opt-in')</td> <td>@lang('profile.opt-in')</td>
<td>{{ $user->opt_in ? __('common.yes') : __('common.no') }}</td> <td>{{ $user->opt_in ? __('common.yes') : __('common.no') }}</td>
</tr> </tr>
@if($user->fields) @if($user->fields)
<tr> <tr>
<td colspan="2"> <td colspan="2"><h5>Custom Fields</h5></td>
<h5>Custom Fields</h5>
</td>
</tr> </tr>
{{-- Custom Fields --}} {{-- Custom Fields --}}
@foreach($user->fields as $field) @foreach($user->fields as $field)
<tr> <tr>
@ -145,4 +137,4 @@
@endif @endif
</table> </table>
</div> </div>
</div> </div>