Итак, у меня есть функция, которая может заполнить мой столбец из базы данных значением 1 при щелчке, и теперь я добавил поле ввода, и мне нужно сохранить текст из нового ввода в столбце decline_reason.
Вот что я пытался сделать:
public function cancelp(requ $request, $id)
{
Reports::find($id)->update(['status' => '0']);
Reports::find($id)->update(['decline_reason' => $request['decline_reason']]);
Session::flash('message', "Report declined");
return Redirect::back();
}
Сейчас
Мой взгляд с кнопкой, которая заполняет мой столбец значением 1
<div class="modal-body">
<label>Specify the reason</label>
<input name="decline_reason" class="form-control" type="text"/>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<a>{{ link_to('admin/reports/p/' . $report->id. '/action-cancel', 'Decline', ['class' => 'btn btn-danger btn-xs']) }}</a>
</div>
Route::get('admin/reports/p/{job}/action-cancel', 'ArticleController@cancelp');
Модель отчетов
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Reports extends Model
{
protected $table = 'reports';
// public $timestamps = false;
protected $fillable = [
'user_id', 'username', 'user_id_posted', 'username_posted', 'news_id','opinion_id','event_id','career_solution_id', 'subject', 'why_reporting','why_reporting_message','additional_message','status', 'comment_id', 'decline_reason'
];
public function career_solutionReport()
{
return $this->belongsTo('App\CareerSolution','career_solution_id','id');
}
public function eventReport()
{
return $this->belongsTo('App\Event','event_id','id');
}
public function newsReport()
{
return $this->belongsTo('App\News','news_id','id');
}
public function opinionReport()
{
return $this->belongsTo('App\Opinion','opinion_id','id');
}
public function user()
{
return $this->belongsTo('App\User','user_id','id');
}
}
На данный момент в базе данных столбец null
.