refactored file migration, view and controller

This commit is contained in:
aslan 2024-02-07 16:33:34 +03:00
parent b1cd352165
commit 93592992b7
4 changed files with 4 additions and 3 deletions

View File

@ -35,9 +35,8 @@ class FileController extends Controller
abort_if(Auth::guest(), 403);
$receptionScreens = ReceptionScreen::pluck('name', 'id');
$idsReceptionScreens = $receptionScreens->keys()->toArray();
$files = File::where('reception_screen_id', '=', $idReceptionScreen)->get();
return view('files.create', compact('receptionScreens', 'idsReceptionScreens', 'idReceptionScreen', 'files'));
return view('files.create', compact('receptionScreens', 'idReceptionScreen', 'files'));
}
public function store(StoreFileRequest $request)

View File

@ -13,6 +13,7 @@ class File extends Model
protected $fillable = [
'id',
'name',
'file_name',
'url',
'description',
];

View File

@ -14,6 +14,7 @@ return new class extends Migration
Schema::create('files', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('file_name')->nullable();
$table->string('description')->nullable();
$table->string('url');
$table->integer('position');

View File

@ -42,7 +42,7 @@
{{ Form::label('idReceptionScreen', 'Пункт экрана приема') }}
</div>
<div class="mt-2">
{{ Form::select('idReceptionScreen', $receptionScreens, $idReceptionScreen, $idsReceptionScreens,['class' => 'form-select']) }}
{{ Form::select('idReceptionScreen', $receptionScreens, $idReceptionScreen, ['class' => 'form-select']) }}
</div>
<div>
@if ($errors->any())