Я хочу передать значение в форму, но по какой-то причине в index.blade я вижу массив, который он заполнен, а для form.blade по какой-то причине массив пуст.
В form.blade я хочу засунуть все уже выбранное значение из массива в iput, а затем обновить информацию Массив возвращает null в edit.blade
SystemController
class SystemController extends Controller{
public function index(){
return view('admin.options.index',[
'options' => DB::table('systems')->first(),
]);
}
public function edit(System $system){
return view('admin.options.edit',[
'array' => $system,
]);
}
public function update(Request $request,System $system){
$system->update($request->except('id'));
/*$last_row = DB::table('systems')->latest()->first();*/
$system->first_column = $request['first_column'];
$system->second_column = $request['second_column'];
$system->third_column = $request['third_column'];
// $system->update($last_row);
$system->save();
return redirect()->route('admin.options.index');
}
index.blade
<tbody>
<?php $array = json_decode(json_encode($options), true); ?>
<?php var_dump($array) ?>
<tr>
< td>{{$array['first_column'] ?? ""}}</td>
<td>{{$array['first_column'] ?? ""}}</td>
<td>{{$array['first_column'] ?? ""}}</td>
<td class="text-right">
<a class="btn btn-default" href="{{route('admin.options.edit', $array)}}"><i class="fa fa- edit"></i></a>
</td>
</tr>
var_dump get
array(4) { ["id"]=> int(4) ["first_column"]=> string(13) "
dsfdsf
" ["second_column"]=> string(15) "
dsfsfdsf
" ["third_column"]=> string(13) "
dsfdsf
" }
edit.blade.php
<form class="form-horizontal" action="{{route('admin.options.update', $array)}}" method="post" >
<input type="hidden" name="_method" value="put">
{{ csrf_field() }}
{{-- Form include --}}
@include('admin.options.partials.form')
form.blade.php
<?php $systemm = (object) $system ?>
<div class="rtq">
<label for="">firsts column</label>
<input type="text" class="form-control" name="first_column" value="{{ $systemm ? $systemm->first_column : '' }}">
</div>
У меня почему то везде в input выводятся 1 1 1 , а не мой контент и я хотел бы сделать update
array в form.blade
object(App\System)#310 (26) { ["timestamps"]=> bool(false) ["fillable":protected]=> array(3) { [0]=> string(12) "first_column" [1]=> string(13) "second_column" [2]=> string(12) "third_column" } ["connection":protected]=> string(5) "mysql" ["table":protected]=> string(7) "systems" ["primaryKey":protected]=> string(2) "id" ["keyType":protected]=> string(3) "int" ["incrementing"]=> bool(true) ["with":protected]=> array(0) { } ["withCount":protected]=> array(0) { } ["perPage":protected]=> int(15) ["exists"]=> bool(true) ["wasRecentlyCreated"]=> bool(false) ["attributes":protected]=> array(4) { ["id"]=> int(9) ["first_column"]=> string(4) "gggg" ["second_column"]=> string(15) "
dsfsfdsf
" ["third_column"]=> string(13) "
dsfdsf
" } ["original":protected]=> array(4) { ["id"]=> int(9) ["first_column"]=> string(4) "gggg" ["second_column"]=> string(15) "
dsfsfdsf
" ["third_column"]=> string(13) "
dsfdsf
" } ["changes":protected]=> array(0) { } ["casts":protected]=> array(0) { } ["dates":protected]=> array(0) { } ["dateFormat":protected]=> NULL ["appends":protected]=> array(0) { } ["dispatchesEvents":protected]=> array(0) { } ["observables":protected]=> array(0) { } ["relations":protected]=> array(0) { } ["touches":protected]=> array(0) { } ["hidden":protected]=> array(0) { } ["visible":protected]=> array(0) { } ["guarded":protected]=> array(1) { [0]=> string(1) "*" } }