I am doing a project in Laravel 5.5. I have the following form to edit a post:
The idea is that the only forms that the user can see are the notes and the description. The rest of the other fields will already have a value in the database so that the user, as he can not see them, can not modify them. I read that there is a way to do it with css, since I only want to hide it visually.
Here I put the code of the form:
{{ Form::hidden('user_id', auth()->user()->id) }}
<div class="form-group">
{{ Form::label('category_id', 'Categorias') }}
{{ Form::select('category_id', $categories, null, ['class' => 'form-control']) }}
</div>
<div class="form-group">
{{ Form::label('name', 'Nombre de la etiqueta') }}
{{ Form::text('name', null, ['class' => 'form-control', 'id' => 'name']) }}
</div>
<div class="form-group">
{{ Form::label('slug', 'URL amigable') }}
{{ Form::text('slug', null, ['class' => 'form-control', 'id' => 'slug']) }}
</div>
<div class="form-group">
{{ Form::label('file', 'Imagen') }}
{{ Form::file('file') }}
<div class="form-group">
{{ Form::label('file2', 'Notas') }}
{{ Form::file('file2') }}
</div>
<div class="form-group">
{{ Form::label('status', 'Estado') }}
<label >
{{ Form::radio('status', 'PUBLISHED') }} Publicado
</label>
<label >
{{ Form::radio('status', 'DRAFT') }} Borrador
</label>
</div>
<div class="form-group">
{{ Form::label('tags', 'Etiquetas') }}
<div>
@foreach($tags as $tag)
<label>
{{ Form::checkbox('tags[]', $tag->id) }} {{ $tag->name }}
</label>
@endforeach
</div>
</div>
<div class="form-group">
{{ Form::label('excerpt', 'Extracto') }}
{{ Form::textarea('excerpt', null, ['class' => 'form-control', 'rows' => '2']) }}
</div>
<div class="form-group">
{{ Form::label('body', 'Descripcion') }}
{{ Form::textarea('body', null, ['class' => 'form-control']) }}
</div>
<div class="form-group">{{ Form::submit('Guardar', ['class' => 'btn btn-sm btn-primary']) }}</div>
@section('scripts')
<script src="{{ asset('vendor/stringToSlug/jquery.stringToSlug.min.js') }}"></script>
<script src="{{ asset('vendor/stringToSlug/jquery.stringToSlug.js') }}"></script>
<script src="{{ asset('vendor/ckeditor/ckeditor.js') }}"></script>
<script>
$(document).ready(function(){
$("#name, #slug").stringToSlug({
callback: function(text){
$('#slug').val(text);
}
});
});
CKEDITOR.config.height = 400;
CKEDITOR.config.width = 'auto';
CKEDITOR.replace('body');
</script>
@endsection
EDIT1: Users are registered in the application.
When an administrator creates or edits a post, he can use all the fields. There is only one administrator, I differentiate it since it has a value in its id of 1, the rest users with id values other than 1 are simple users.
When a user creates a post, he can use all the fields. When a user edits a post, he can only edit the notes field and the description field, so that the other fields retain the values that were placed when the post was created.