Here is the Gallery.php model
<?php
class Gallery extends \Eloquent {
protected $fillable = array('title', 'content', 'image');
protected $guarded = array('id');
protected $table = 'gallery';
public static $rules = array(
'title' => '',
'content' => '',
'image' => ''
);
}
Describe "everything except for the image has been posted" . Try PUT instead of PATCH. What fields are not updating (i assume by updating you mean saving to database, right ?) and what fields are updated via your code ?
I tried PUT but still nothing. In my edit.blade.php I have these fields:
title content image
title and content is being posted with the changes that was made but image has a blank to it so it looks like this
Array
(
[_method] => PUT
[_token] => AuY9NBP5MkfX0mNCBnwt1QKViI01cl9F5bWnGkYc
[title] => test 33
[content] =>
test
[image] =>
)
and yes I'm saving to the database. And the only things that get updated is my title and content
If your application is in $debug = true; mode you can see the sql update query via debug console down-left laravel icon on the rendered view (browser). Paste it here. What type of data is your database column 'image' ?
My application does have 'debug' => true, but I don't see the query anywhere or the laravel icon. My image column is a varchar in my database.
I can't really tell what all the ajax stuff is doing, but I did notice two things. First, there is a {{ Form::open() }} tag at the bottom of your form instead of {{ Form::close() }}. Also, you might need to set the files option to true in order to set the form's enctype attribute to multipart/form-data.
{{ Form::model($galleries, array('files' => 'true', 'method' => 'PATCH', 'route' => array('admin.gallery.update', $galleries->id))) }}
Maybe fill me in a bit more on the AJAX stuff? After the updates, if you die and dump the input in the controller what do you see?
dd($input);
When I put
dd($input)
I get
array (size=5)
'_method' => string 'PATCH' (length=5)
'_token' => string 'cOOg56pbcKJ3BDgsQWL6MGxK4CO1SXdGRq8rd1rV' (length=40)
'title' => string 'test' (length=4)
'content' => string '<p>test</p>' (length=11)
'image' => string '' (length=0)
In a nutshell, the ajax is suppose to find the class test-upload and get the image and push it through to the POST section.
I hope that makes sense
It's an issue with the ajax stuff for sure. I don't know what plugin that is and it's really hard to help without seeing more. Sorry! Seems sort of complicated though? Maybe try to simplify your UI if you can. Use one form for the gallery title, description, etc. Use another form for the file uploads, and then have remove buttons for each image.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community