我不能編輯的即時通訊在我的控制器創建這樣一個項目:廣東話執行UPDATE操作 - 編輯項目
public function newProject(Request $request)
{
$data = $request->all();
$attributes = [];
$attributes['title'] = $data['title'];
$attributes['start_date'] = date("Y-m-d h:i:s", strtotime($data['start_date']));
$attributes['end_date'] = date("Y-m-d h:i:s", strtotime($data['end_date']));
$attributes['created_by'] = Auth::user()->id;
$attributes['description'] = $data['description'];
$attributes['air'] = '10';
$attributes['water'] = '19';
$attributes['lat'] = $data['lat'];
$attributes['lng'] = $data['lng'];
// var_dump($attributes);
// return;
$project = Projects::create($attributes);
if($project)
return redirect('home')->with('success', 'Project added successfully');
var_dump($data);
return;
}
現在,我想編輯我上述功能創建的項目。我嘗試了相同的步驟,只是對路線進行了更改:
Route::post('projects/new', [
'uses' => '[email protected]',
'as' => 'projects.new',
]);
注意:這是我創建項目的函數和路由。任何提示如何編輯?
UPDATE:
我的刀片模板文件
@extends('layouts.app')
@section('content')
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="panel panel-default">
<div class="panel-heading">Add Project</div>
<div class="panel-body">
<form class="form-horizontal" role="form" method="POST" action="{{ route('projects.update') }}">
{{ csrf_field() }}
<div class="form-group{{ $errors->has('title') ? ' has-error' : '' }}">
<label for="title" class="col-md-4 control-label">Title</label>
<div class="col-md-7">
<input id="title" type="text" class="form-control" name="title" value="{{ $project->title }}">
@if ($errors->has('title'))
<span class="help-block">
<strong>{{ $errors->first('title') }}</strong>
</span>
@endif
</div>
</div>
<div class="form-group{{ $errors->has('date') ? ' has-error' : '' }}">
<label for="email" class="col-md-4 control-label">Start Date</label>
<div class="col-md-7">
<input id="date" type="date" class="form-control" name="start_date" value="{{ $project->start_date }}">
@if ($errors->has('date'))
<span class="help-block">
<strong>{{ $errors->first('date') }}</strong>
</span>
@endif
</div>
</div>
<div class="form-group{{ $errors->has('date') ? ' has-error' : '' }}">
<label for="date" class="col-md-4 control-label">End Date</label>
<div class="col-md-7">
<input id="date" type="date" class="form-control" name="end_date" value="{{ $project->end_date }}">
@if ($errors->has('date '))
<span class="help-block">
<strong>{{ $errors->first('date') }}</strong>
</span>
@endif
</div>
</div>
<div class="form-group{{ $errors->has('text') ? ' has-error' : '' }}">
<label for="email" class="col-md-4 control-label">Description</label>
<div class="col-md-7">
<textarea class="form-control" rows="3" name="description" >{{ $project->description }} </textarea>
@if ($errors->has('email'))
<span class="help-block">
<strong>{{ $errors->first('textarea') }}</strong>
</span>
@endif
</div>
</div>
<label class="col-md-7 control-label"></label>
<span>
<a class="btn btn-primary" data-toggle="collapse" href="#collapseExample" aria-expanded="false" aria-controls="collapseExample" >
Air
</a>
</span>
<span>
<a class="btn btn-primary" data-toggle="collapse" href="#collapseExample2" aria-expanded="false" aria-controls="collapseExample2">
Water
</a>
</span>
<span>
<a class="btn btn-primary" data-toggle="collapse" href="#collapseExample3" aria-expanded="false" aria-controls="collapseExample">
Location
</a>
</span>
<div class="collapse" id="collapseExample">
<div class="form-group{{ $errors->has('number') ? ' has-error' : '' }}">
<label for="text" class="col-md-4 control-label">Temperature</label>
<div class="row">
<div class="col-xs-1">
<input type="text" name="temperature" class="form-control" placeholder=" °C" value="{{$project->temperature}}">
</div>
</div>
</div>
<div class="form-group{{ $errors->has('number') ? ' has-error' : '' }}">
<label for="text" class="col-md-4 control-label">Radiation</label>
<div class="row">
<div class="col-xs-1">
<input type="text" name="radiation" class="form-control" placeholder=".col-xs-1" vlaue="{{$project->radiation}}">
</div>
</div>
</div>
<div class="form-group{{ $errors->has('number') ? ' has-error' : '' }}">
<label for="text" class="col-md-4 control-label">Dust</label>
<div class="row">
<div class="col-xs-1">
<input type="text" name="dust" class="form-control" placeholder=".col-xs-1" value="{{$project->dust}}">
</div>
</div>
</div>
<div class="form-group{{ $errors->has('number') ? ' has-error' : '' }}">
<label for="text" class="col-md-4 control-label">Noise</label>
<div class="row">
<div class="col-xs-1">
<input type="text" name="noise" class="form-control" placeholder=".col-xs-1" value="{{$project->noise}}">
</div>
</div>
</div>
</div>
<p> </p>
<div class="collapse" id="collapseExample2">
<div class="form-group{{ $errors->has('number') ? ' has-error' : '' }}">
<label for="text" class="col-md-7 control-label">Natrium</label>
<div class="row">
<div class="col-xs-1">
<input type="text" name="natrium" class="form-control" placeholder=".col-xs-1" value="{{$project->natrium}}">
</div>
</div>
</div>
<div class="form-group{{ $errors->has('number') ? ' has-error' : '' }}">
<label for="text" class="col-md-7 control-label">Phosporus</label>
<div class="row">
<div class="col-xs-1">
<input type="text" name="phosporus" class="form-control" placeholder=".col-xs-1" value="{{$project->phosphorus}}">
</div>
</div>
</div>
<div class="form-group{{ $errors->has('number') ? ' has-error' : '' }}">
<label for="text" class="col-md-7 control-label">Arsinic</label>
<div class="row">
<div class="col-xs-1">
<input type="text" name="arsinic" class="form-control" placeholder=".col-xs-1" value="{{$project->arsinic}}">
</div>
</div>
</div>
<div class="form-group{{ $errors->has('number') ? ' has-error' : '' }}">
<label for="text" class="col-md-7 control-label">Barium</label>
<div class="row">
<div class="col-xs-1">
<input type="text" name="barium" class="form-control" placeholder=".col-xs-1" value="{{$project->barium}}">
</div>
</div>
</div>
<div class="form-group{{ $errors->has('number') ? ' has-error' : '' }}">
<label for="text" class="col-md-7 control-label">Cadmium</label>
<div class="row">
<div class="col-xs-1">
<input type="text" name="cadmium" class="form-control" placeholder=".col-xs-1" value="{{$project->cadium}}">
</div>
</div>
</div>
<div class="form-group{{ $errors->has('number') ? ' has-error' : '' }}">
<label for="text" class="col-md-7 control-label">Mercury</label>
<div class="row">
<div class="col-xs-1">
<input type="text" name="mercury " class="form-control" placeholder=".col-xs-1" value="{{$project->mercury}}">
</div>
</div>
</div>
<div class="form-group{{ $errors->has('number') ? ' has-error' : '' }}">
<label for="text" class="col-md-7 control-label">Selenium</label>
<div class="row">
<div class="col-xs-1">
<input type="text" name="selenium" class="form-control" placeholder=".col-xs-1" value="{{$project->selenium}}">
</div>
</div>
</div>
<div class="form-group{{ $errors->has('number') ? ' has-error' : '' }}">
<label for="text" class="col-md-7 control-label">Nickel </label>
<div class="row">
<div class="col-xs-1">
<input type="text" name="nickel" class="form-control" placeholder=".col-xs-1" value="{{$project->nickel}}">
</div>
</div>
</div>
<div class="form-group{{ $errors->has('number') ? ' has-error' : '' }}">
<label for="text" class="col-md-7 control-label">Thallium</label>
<div class="row">
<div class="col-xs-1">
<input type="text" name="thallium" class="form-control" placeholder=".col-xs-1" value="{{$project->thallium}}">
</div>
</div>
</div>
<div class="form-group{{ $errors->has('number') ? ' has-error' : '' }}">
<label for="text" class="col-md-7 control-label">Berillyum</label>
<div class="row">
<div class="col-xs-1">
<input type="text" name="berillyum" class="form-control" placeholder=".col-xs-1" value="{{$project->berillyum}}">
</div>
</div>
</div>
<div class="form-group{{ $errors->has('number') ? ' has-error' : '' }}">
<label for="text" class="col-md-7 control-label">Phenols</label>
<div class="row">
<div class="col-xs-1">
<input type="text" name="phenols" class="form-control" placeholder=".col-xs-1" value="{{$project->phenols}}">
</div>
</div>
</div>
<div class="form-group{{ $errors->has('number') ? ' has-error' : '' }}">
<label for="text" class="col-md-7 control-label">Oil</label>
<div class="row">
<div class="col-xs-1">
<input type="text" name="oil" class="form-control" placeholder=".col-xs-1" value="{{$project->oil}}">
</div>
</div>
</div>
<div class="form-group{{ $errors->has('number') ? ' has-error' : '' }}">
<label for="text" class="col-md-7 control-label">Temperature</label>
<div class="row">
<div class="col-xs-1">
<input type="text" name="w_temperature" class="form-control" placeholder="°C" value="{{$project->w_temperature}}">
</div>
</div>
</div>
<div class="form-group{{ $errors->has('number') ? ' has-error' : '' }}">
<label for="text" class="col-md-7 control-label">Oxygen</label>
<div class="row">
<div class="col-xs-1">
<input type="text" name="oxygen" class="form-control" placeholder="mg/L" value="{{$project->oxygen}}">
</div>
</div>
</div>
</div>
<label for="text" class="col-md-4 control-label">Location</label>
<div class="row">
<div class="col-md-7">
<h1>Location</h1>
<p></p>
<!--map div-->
<div id="map"></div>
<!--our form-->
<h2 class="text-left">Coordinates</h2>
<p>
<input class="form-control" type="text" id="lat" name="lat" value="{{$project->lat}}" />
<input class="form-control" type="text" id="lng" name="lng" value="{{$project->lng}}"/>
</p>
</div>
</div>
<div class="form-group">
<div class="col-md-7 col-md-offset-4">
<button type="submit" class="btn btn-primary">
<i class="fa fa-btn fa-user"></i> Add Project
</button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
@endsection
@section('footer')
@endsection
您是否收到錯誤或什麼? – Samsquanch