Level 122
Have you setup the $fillable array?
personally I would probably use $request and explicitly set the photo name
$profile = new Profile;
$profile->fill($request->all());
$profile->photo = $name;
$profile->save();
I have the following code to upload an image to the database. My problem is when I do this, other fields don't get populated. Do I have to do $input['field1'] for every field I have?
public function store(Request $request) { if($file = $request->file('photo')) {
$name = time() . $file->getClientOriginalName();
$file->move('images', $name);
//$photo = Photo::create(['file'=>$name]);
$input['photo'] = $name;
}
Profile::create($input);
}
Have you setup the $fillable array?
personally I would probably use $request and explicitly set the photo name
$profile = new Profile;
$profile->fill($request->all());
$profile->photo = $name;
$profile->save();
Please or to participate in this conversation.