Teşekkürler. Bir deneme yaptım fakat hata da almıyorum. Formu post ettiğim zaman kayıt işlemini yapmıyor ve form sayfası verilerini kaybetmeden yine karşıma geliyor. Sizce problem ne olabilir?
Request dosyam:
<?php namespace App\Http\Requests;
use App\Http\Requests\Request;
class CreateDocumentRequest extends Request {
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'category_id' => 'required',
'slug' => 'required',
'title' => 'required',
'description' => 'required',
'details' => 'required',
'owner' => 'required',
'updater' => 'required',
'status' => 'required',
'keywords' => 'required',
'order_by' => 'required'
];
}
}
Store methodum:
public function store(CreateDocumentRequest $request, Document $document){
$document->create($request->all());
return redirect('admin/content/documents')
->with('main_message', 'Document has been successfully created');
}
Model dosyam:
<?php namespace App;
use Illuminate\Database\Eloquent\Model as Eloquent;
class Document extends Eloquent{
protected $table = "documents";
public $timestamps = true;
protected $fillable = ['title', 'slug', 'category_id', 'description', 'details', 'keywords', 'owner', 'updater', 'status', 'order_by'];
public function category(){
return $this->belongsTo('App\Category', 'category_id');
}
public function updateInfo(){
return $this->belongsTo('App\User', 'updater');
}
public function createInfo(){
return $this->belongsTo('App\User', 'owner');
}
public static function boot()
{
parent::boot();
static::creating(function ($document) {
$document->owner = \Auth::user()->id;
$document->updater = \Auth::user()->id;
});
}
}
Bunlarda form alanlarım.
<div class="form-group {{ $errors->has('category_id') ? 'has-error' : '' }}">
{!! Form::label('category_id', 'Category') !!}
{!! Form::select('category_id', array('' => 'Please Select a Category') + $categories, null, ['class' => 'form-control']) !!}
{!! $errors->first('category_id', '<div class="help-block">:message</div>') !!}
</div>
<div class="form-group {{ $errors->has('title') ? 'has-error' : '' }}">
{!! Form::label('title', 'Title') !!}
{!! Form::text('title', NULL, array('class' => 'form-control')) !!}
{!! $errors->first('title', '<div class="help-block">:message</div>') !!}
</div>
<div class="form-group {{ $errors->has('slug') ? 'has-error' : '' }}">
{!! Form::label('slug', 'Slug') !!}
{!! Form::text('slug', NULL, array('class' => 'form-control slug')) !!}
{!! $errors->first('slug', '<div class="help-block">:message</div>') !!}
</div>
<div class="form-group {{ $errors->has('description') ? 'has-error' : '' }}">
{!! Form::label('description', 'Description') !!}
{!! Form::text('description', NULL, array('class' => 'form-control')) !!}
{!! $errors->first('description', '<div class="help-block">:message</div>') !!}
</div>
<div class="form-group {{ $errors->has('details') ? 'has-error' : '' }}">
{!! Form::label('details', 'Details') !!}
{!! Form::textarea('details', NULL, array('class' => 'form-control')) !!}
{!! $errors->first('details', '<div class="help-block">:message</div>') !!}
</div>
<div class="form-group {{ $errors->has('keywords') ? 'has-error' : '' }}">
{!! Form::label('keywords', 'Keywords') !!}
{!! Form::text('keywords', NULL, array('class' => 'form-control')) !!}
{!! $errors->first('keywords', '<div class="help-block">:message</div>') !!}
</div>
<div class="form-group {{ $errors->has('status') ? 'has-error' : '' }}">
{!! Form::label('status', 'Status') !!}
{!! Form::select('status', array('1' => 'Published', '0' => 'Unpublished'), null, ['class' => 'form-control']) !!}
{!! $errors->first('status', '<div class="help-block">:message</div>') !!}
</div>
<div class="form-group {{ $errors->has('order_by') ? 'has-error' : '' }}">
{!! Form::label('order_by', 'Order') !!}
{!! Form::number('order_by', NULL, array('class' => 'form-control')) !!}
{!! $errors->first('order_by', '<div class="help-block">:message</div>') !!}
</div>
<script>
CKEDITOR.replace( 'details' );
</script>
Hata verse sebebine bakacağım ama herhangi bir hata da basmıyor ekrana