I think you are kinda wrong way. Here is the ideal way to insert. For instance-
$flight = new Flight;
$flight->name = $request->name;
$flight->save()
Ref: https://laravel.com/docs/5.5/eloquent#inserting-and-updating-models
I am trying to create a profile page that includes adding of image and i got this error [Creating default object from empty value].
Here is my migration file: public function up() { Schema::create('profiles', function (Blueprint $table) { $table->increments('id'); $table->integer('user_id'); $table->string('photo'); $table->string('address'); $table->string('ethnicity'); $table->string('state'); $table->timestamps(); }); }
Here is my controller public function store(Request $request) { //validate form $this->validate($request,[ 'photo' => 'required|mimes:jpg,png,jpeg,bmp', 'address' => 'required|max:191', 'ethnic' => 'required|min:3', 'state' => 'required', ]); Session(); $user = new User; $profiles = new profile; $profiles->photo = $request->input('photo'); $profiles->address = $request->input('address'); $profiles->ethnic = $request->input('ethnic'); $profiles->state = $request->input('state'); $profile->user_id = auth()->user()->id; return auth()->user()->id; exit(); } Here is my form:
{{csrf_field()}} Fullname My Location Mobile Upload Picture Home Address Ethnicity State of Origin Submit Profile</div>
Please or to participate in this conversation.