php


Use of undefined constant while storing data from form


I have created a model
Review.php
and resource controller for it
ReviewController.php
with route
Route::resource('review','ReviewController');
and created a form to get the values. My store method:
public function store(Request $request)
{
$this->validate($request, [
'fullname' => 'required|max:255',
'email' => 'required',
'country' => 'required',
'tourname' => 'required',
'content' => 'required'
]);
$reviews = new Review;
$reviews->name = $request->fullname;
$reviews->email = $request->email;
$reviews->country = $request->country;
$reviews->content = $request->content;
$reviews->tour_id = $request->tourname;
if($request->hasFile('clidentpp')){
$image = $request->file('clidentpp');
$filename = time().'.'.$image->getClientOriginalName();
$location = public_path('images/client_review'.$filename);
Image::make($image)->resize(128, 128)->save($location);
$reviews->path = $location;
}
$reviews->save();
Session::flash('success','Thank you for your review !');
return back()->withInput(['tab'=>'complete']);
}
I'm getting error
Use of undefined constant reviews - assumed 'reviews'
pointing at line $reviews = new Review;. I tried changing$reviews to $review also still no luck.
It should be $reviews = new Review();
Try this.
$review[] = '';
$review['name'] = $request->fullname;
$review['email'] = $request->email;
...
Review::create($review);

Related Links

Laravel 4 installation issue
database field data not appearing in form textbox in PHP
How to match following combination of letters
Redirecting Issue - Site working fine in desktop but redirecting on mobile
Get App name from APK
Simple wordpress is_single get the category id
saving relative values with cakephp
Users Tree system, horizontal, self-join
PHP escaping \14 character in file paths
Laravel lists function prepend value
php pregsplit regex for parenthesis
Swapping elements in an array according to some criteria
Laravel 5.1 - Nested Loop - Blade Templating
jQuery UI Autocomplete Multiple Remote (JSON, PHP, JS)
How to transform the & to & appearing in autocomplete dropdown
What could be wrong with my config.php?

Categories

HOME
postgresql-9.4
loopbackjs
openlayers-3
histogram
jint
mutation-testing
hystrix
driver
fireloop
powermock
significance
amazon-mws
error-logging
tableview
weex
hdl
bosun
candlestick-chart
cell
raima
docx4j
xenapp
snap-framework
python-2.x
private-key
buildforge
forms-authentication
elastica
rdp
selenide
task-parallel-library
microkernel
game-center
haar-classifier
fluid-mac-app-engine
sendinput
sonarqube5.2
cordova-ios
sigsegv
winmerge
gnome-terminal
polymaps
gmaps.js
bpms
ogg
ternary-operator
dpkg
node-glob
timestamping
mnesia
as3-api
taco
wif4.5
srv-record
highest
knife
com0com
famo.us
configurable-product
storing-data
code-complexity
forceclose
meteor-collections
colon
stty
objective-c-runtime
delphi-xe4
donut-chart
examine
xmlwriter
border-box
voice-recording
kolite
azure-acs
bll
django-pagination
mygeneration
sscli
browser-based
rakudo
error-detection

Resources

Encrypt Message