Save a File To mysql Database From a form using laravel - php

Good day Everyone, I'm less than 1 week old in laravel. I'm trying to save a Register CV page to MySQL database. Although my Form contains an upload file. While saving it to the database only the name of the file is saved the file itself isnt there.
My code goes thus.
RegisterController.php
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\candidate;
use App\Http\Requests;
class RegisterController extends Controller
{
public function register(Request $request) {
$this->validate($request, [
'surname' => 'required',
'other_name' => 'required',
'email' => 'required',
'phone' => 'required',
'gender' => 'required',
'field' => 'required',
'qualification' => 'required',
'resume' => 'required'
]);
$candidates = new Candidate;
$candidates->surname = $request->input('surname');
$candidates->other_name = $request->input('other_name');
$candidates->email = $request->input('email');
$candidates->phone = $request->input('phone');
$candidates->gender = $request->input('gender');
$candidates->field = $request->input('field');
$candidates->qualification = $request->input('qualification');
$candidates->resume = $request->input('resume');
$candidates->save();
return redirect('/career')->with('response', 'Registered Successfully');
}
}
2018_03_28_152114_create_candidates_table.php
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateCandidatesTable extends Migration
{
/**
* Run the migrations.
*
* #return void
*/
public function up()
{
Schema::create('candidates', function (Blueprint $table) {
$table->increments('id');
$table->string('surname');
$table->string('other_name');
$table->string('email');
$table->string('phone');
$table->string('gender');
$table->string('field');
$table->string('qualification');
$table->string('resume');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* #return void
*/
public function down()
{
Schema::dropIfExists('candidates');
}
}
then the form
<form class="form-horizontal pv-20" action="/career/test-apply" method="POST" role="form">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
.........
........
<div class="form-group">
<label class="col-sm-2" for="resume">Upload Resume</label>
<div class="col-sm-10">
<input class="form-control" type="file" name="resume" id="resume" accept="application/pdf">
</div>
</div>
<div class="form-group">
<label class="col-sm-6" for="resume"></label>
<div class="col-sm-6">
<button type="submit" class="btn btn-default btn-curve btn-animated pull-right">Submit <i class="fa fa-play"></i></button>
</div>
</div>
</form>

You can save the file in the Public directory of your project. Then, you can just save the name of the file in MySQL database.

Related

Why registerController is not inserting data to database in laravel

I am new to laravel. I want to insert users data to database using registerController in laravel.
What I have tried is:
register.blade.php
#extends('adminlte::auth.auth-page', ['auth_type' => 'register'])
#php( $login_url = View::getSection('login_url') ?? config('adminlte.login_url', 'login') )
#php( $register_url = View::getSection('register_url') ?? config('adminlte.register_url', 'register') )
#if (config('adminlte.use_route_url', false))
#php( $login_url = $login_url ? route($login_url) : '' )
#php( $register_url = $register_url ? route($register_url) : '' )
#else
#php( $login_url = $login_url ? url($login_url) : '' )
#php( $register_url = $register_url ? url($register_url) : '' )
#endif
#section('auth_header', __('adminlte::adminlte.register_message'))
#section('auth_body')
<?php $res= DB::table('states')->orderBy('name','asc')->get();
?>
<form method="POST" action="{{ route('register_user') }}" class="registerForm">
#csrf
<div class="row">
<div class="col-md-6">
{{-- First Name field --}}
<div class="col-md-6">
<div class="input-group form-group">
<input type="text" class="form-control" placeholder="First Name *" name="first_name" value="" required>
</div>
</div>
</div>
<div class="col-md-6">
<div class="input-group form-group">
<input type="text" class="form-control" placeholder="Last Name *" name="last_name" value="" required>
</div>
</div>
<div class="col-md-6">
<div class="input-group form-group">
<input type="email" class="form-control" name="email" value="" placeholder="Email *" required>
</div>
</div>
<div class="col-md-6">
<div class="input-group form-group">
<input type="text" class="form-control phoneMask" placeholder="Phone *" name="phone" value="" required>
</div>
</div>
<div class="row">
<div class="col-md-3 col-xs-offset-4 submit_btn">
{{-- Register button --}}
<button type="submit" class="btn btn-block {{ config('adminlte.classes_auth_btn', 'btn-flat btn-primary') }}">
<span class="fas fa-user-plus"></span>
{{ __('adminlte::adminlte.register') }}
</button>
</div>
</div>
</div>
</form>
#stop
#section('auth_footer')
<p class="my-0">
<a href="{{ route('login') }}">
{{ __('adminlte::adminlte.i_already_have_a_membership') }}
</a>
</p>
#stop
RegisterController.php
<?php
namespace App\Http\Controllers\Auth;
use Illuminate\Http\Request;
use Illuminate\Auth\Events\Registered;
use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use App\User;
use Illuminate\Foundation\Auth\RegistersUsers;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;
use Carbon\Carbon;
use Auth;
class RegisterController extends Controller
{
/*
|--------------------------------------------------------------------------
| Register Controller
|--------------------------------------------------------------------------
|
| This controller handles the registration of new users as well as their
| validation and creation. By default this controller uses a trait to
| provide this functionality without requiring any additional code.
|
*/
use RegistersUsers;
/**
* Where to redirect users after registration.
*
* #var string
*/
protected $redirectTo = '/home';
/**
* Create a new controller instance.
*
* #return void
*/
public function __construct()
{
$this->middleware('guest');
}
/**
* Get a validator for an incoming registration request.
*
* #param array $data
* #return \Illuminate\Contracts\Validation\Validator
*/
protected function validator(array $data)
{
return Validator::make($data, [
'first_name' => ['required', 'string', 'max:255'],
'email' => ['required', 'string', 'email', 'max:255', 'unique:users']
//'password' => ['required', 'string', 'min:8', 'confirmed'],
]);
}
/**
* Create a new user instance after a valid registration.
*
* #param array $data
* #return \App\User
*/
/*protected function create(array $data)
{
/*return User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => Hash::make($data['password']),
]);
dd($data);
$user= User::create([
'first_name' => $data['first_name'],
'last_name' => $data['last_name'],
'email' => $data['email'],
'password' => Hash::make($data['password']),
'mobile' => $data['phone']
]);
// dd($data['password'], $user->password);
return $user;
}*/
public function registerUsers(Request $request)
{
$first_name=$request->input('first_name');
$last_name=$request->input('last_name');
$email=$request->input('email');
$phone=$request->input('phone');
dd($request);
DB::insert('insert into users(first_name,last_name,email,phone)values(?,?,?,?)',[$first_name,$last_name,$email,$phone]);
}
}
web.php
Route::get('/', function () {
return view('auth.login');
});
Auth::routes();
Route::get('/home', 'HomeController#index')->name('home');
Route::post('/register_user', 'Auth\RegisterController#registerUsers')->name('register_user');
Model
class User extends Authenticatable implements AuditableContract
{
use HasApiTokens, Notifiable;
use SoftDeletes;
use Auditable;
/**
* The attributes that are mass assignable.
*
* #var array
*/
protected $hidden = [
'password', 'remember_token',
];
/**
* The attributes that should be cast to native types.
*
* #var array
*/
protected $casts = [
'email_verified_at' => 'datetime',
];
protected $fillable = ['first_name', 'last_name','email','phone','device_token','password','approved','added_by','removed','removed_by','deleted_at'];
}
When I try to submit this form, it is not inserting data to database and is showing HTTP error 500 and couldn't handle request.
What my form looks like
How to fix and insert data to database.
Try to add the cross-fire request forgery to your form. Generally I get this error when I forget it.
Add it like that in your view:
<?php $res= DB::table('states')->orderBy('name','asc')->get(); ?>
<form method="POST" action="{{ route('register_user') }}" class="registerForm">
#csrf
<div class="row">
<div class="col-md-6">
{{-- First Name field --}}
Route
Route::post('/test', 'Auth\RegisterController#test')->name('test');
Auth\RegisterController
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;
.
.
.
public function test ( Request $request){
$rules = array(
'first_name' => 'required', 'string', 'max:255',
// add validation rules here
);
$validator = Validator::make($request->all(), $rules);
if ($validator->passes()) {
$user = new User();
$user->name = $request->input('first_name');
//copy above line and add remaining fields.
$user->save();
return redirect()->back()->with(array('message' => 'user added.'));
} else {
return redirect()->back()->withErrors($validator)->withInput();
}
}
follow these steps
make sure your request received by the desired route
make sure you have passed validation
then input data like this
DB::table('post')->insert([
DB::table('posts')->insert([
'name_name' => \request()->name,
'last_name' => \request()->last_name,
'email' => \request()->email,
'phone' => \request()->phone,
]);

Laravel 8 - Save multiple checkbox selections with separate field to pivot table

Background:
Laravel 8 + Bootstrap 5
I'm pulling a list of licence categories from database to the form.
In the form user is asked to tick which licence to assign to the user. (up to that point I'm OK)
Target
I'd like licence expiry date to be assigned to every category selected.
Code
blade.php
<div class="mb-1"><strong>Assign user's driving licence categories:</strong></div>
#foreach($categories as $category)
<div class="input-group mb-3">
<div class="input-group-text" style="width: 6ch !important;">{{$category->name}}</div>
<div class="input-group-text">
<input class="form-check-input" type="checkbox" name="categories[]" value="{{$category->id}}">
</div>
<div class="input-group-text">Expiry date</div>
<input class="form-control" type="date" name="expiry_date[]">
</div>
#endforeach
Form screenshot
pivot table migration
public function up()
{
Schema::create('driving_licence_category_user', function (Blueprint $table) {
$table->id();
$table->string('driving_licence_category_id');
$table->string('user_id');
$table->string('expiry_date')->nullable();
$table->timestamps();
});
}
models
User
public function drivingLicenceCategory()
{
return $this->belongsToMany('App\Models\DrivingLicenceCategory')
->withPivot('expiry_date')
->withTimestamps();
}
Licence
public function userHasDrivingLicenceCategory()
{
return $this->belongsToMany('App\Models\User');
}
UserController
public function store(Request $request)
{
$request->validate([
'first_name' => 'required',
'last_name' => 'required',
'email' => 'required',
'roles' => 'required',
'categories' => 'required',
'expiry_date' => 'required'
]);
$user = User::create($request->except(['roles', 'categories', 'expiry_date']))
->syncRoles($request->roles)
->drivingLicenceCategory()->sync($request->only('categories'));
//missing code to store the expiry_date information
return redirect()->route('users.index')->with('success', 'User added successfully.');
}
Thank you for spending time on this post :)

Laravel 5.8 PDF upload

for my website I need a form which includes a file upload for PDF files, but I'm new to these and don't really know how to do it.
This is what I got so far, but keep getting:
"Too few arguments to function App\Http\Controllers\FileController::create(), 0 passed and exactly 1 expected"
Controller:
<?php
namespace App\Http\Controllers;
use App\User;
use App\Payment;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;
class FileController extends Controller
{
public function index(){
$users = User::all();
return view('fileupload.create', compact('users'));
}
protected function create(array $data)
{
$request = app('request');
if($request->hasfile('file')){
$file = $request->file('file');
$filename = $file['filename']->getClientOriginalExtension();
Storage::make($file)->save( public_path('/storage/loonstrookjes/' . $filename) );
dd($filename);
}
return Payment::create([
'file_name' => $filename,
'file_path' => '/storage/loonstrookjes/',
'user_id' => $data['employee'],
]);
return route('fileupload.create');
}
}
Model User:
<?php
namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Kyslik\ColumnSortable\Sortable;
class User extends Authenticatable
{
use Notifiable;
use Sortable;
/**
* The attributes that are mass assignable.
*
* #var array
*/
protected $table = 'users';
protected $fillable = [
'username', 'first_name', 'last_name', 'email', 'password',
];
/**
* The attributes that should be hidden for arrays.
*
* #var array
*/
protected $hidden = [
'password', 'remember_token',
];
/**
* The attributes that should be cast to native types.
*
* #var array
*/
protected $casts = [
'email_verified_at' => 'datetime',
];
}
Model Payment:
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Payment extends Model
{
protected $table = 'payment_list';
protected $fillable = [
'user_id', 'file_name', 'file_path'
];
/**
* The attributes that should be hidden for arrays.
*
* #var array
*/
protected $hidden = [
'id', 'file_name', 'file_path'
];
}
View:
#extends('layouts.master')
#section('content')
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<div class="card-header">{{ __('Loonstrook uploaden') }}</div>
<div class="card-body">
<form method="POST" action="{{ route('create') }}" enctype="multipart/form-data">
#csrf
<div class="form-group row">
<label for="filename" class="col-md-4 col-form-label text-md-right">{{ __('Bestandsnaam') }}</label>
<div class="col-md-6">
<input id="filename" type="text" class="form-control{{ $errors->has('filename') ? ' is-invalid' : '' }}" name="filename" value="{{ old('filename') }}" required autofocus>
#if ($errors->has('filename'))
<span class="invalid-feedback" role="alert">
<strong>{{ $errors->first('filename') }}</strong>
</span>
#endif
</div>
</div>
<div class="form-group row">
<label for="file" class="col-md-4 col-form-label text-md-right">{{ __('Bestand') }}</label>
<div class="col-md-6">
<input id="file" type="file" class="form-control" name="file">
</div>
</div>
<div class="form-group row">
<label for="usertype" class="col-md-4 col-form-label text-md-right">{{ __('Werknemer:') }}</label>
<div class="col-md-6">
<select class="form-control" name="type">
#foreach($users as $user)
<option value="{{$user->id}}">{{$user->first_name}} {{$user->last_name}}</option>
#endforeach
</select>
</div>
</div>
<div class="form-group row mb-0">
<div class="col-md-6 offset-md-4">
<button type="submit" class="btn btn-primary">
{{ __('Uploaden') }}
</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
#endsection
These are my routes:
Route::get('/create', 'FileController#index')->name('create');
Route::post('/create', 'FileController#create');
I hope someone can help me find out what's wrong or a better way to do this. Thank you in advance!!
EDIT:
Your answers have helped me quite a bit, but now I'm facing another issue...
The controller now looks like this:
<?php
namespace App\Http\Controllers;
use App\User;
use App\Payment;
use Illuminate\Support\Facades\Validator;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;
use Symfony\Component\HttpFoundation\File\UploadedFile;
UploadedFile::getMaxFilesize();
class FileController extends Controller
{
public function index(){
$users = User::all();
return view('fileupload.create', compact('users'));
}
protected function validator(array $data)
{
return Validator::make($data, [
'filename' => ['required', 'string', 'max:255'],
'file' => ['required', 'file'],
'user_id' => ['required'],
]);
}
protected function create(Request $request)
{
$request = app('request');
if($request->hasfile('file')){
$file = $request->file('file');
$filename = $request->input('filename');
$file = $filename . '.' . $file->getClientOriginalExtension();
$file_path = storage_path('/loonstrookjes');
Storage::disk('local')->putFile($file_path, new File($request->file), $file);
//$path = $request->file('file')->store( storage_path('/storage/loonstrookjes/'));
//$path = Storage::putFile(storage_path('/loonstrookjes/'), $filename);
//dd($upload);
//return $put;
}
return Payment::create([
'file_name' => $filename,
'file_path' => '/storage/loonstrookjes/',
'user_id' => $request['user'],
]);
return route('fileupload.create');
}
}
But I'm getting a new error, this time it's:
Call to undefined method Illuminate\Support\Facades\File::hashName()
Any ideas??
Your problem is you have a parameter in your method create(array $data), but you are posting the form using only {{ route('create') }}. Here you are calling the method by this route without passing the required parameter as you defined it.
Basically, a form post method can accept the requested values by this
protected function create(Request $request)
Because you already used Request as a trait.
So, by this, you can get the requested field value from your form. And you don't have to use $request = app('request'); since you already have it on the parameter variable $request.
In case you want to know
Variables are passed from frontend (view)
to the backend (route) by using {{ route('update', $the_variable) }}.
By this, you can have $the_variable after the last / of your route.
Hope this helps.
Route:
Route::resource('File','FileController');
Controller changes:
public function store(Request $request)
{
if($request->hasfile('file')){
$file = $request->file('file');
$filename = $file['filename']->getClientOriginalExtension();
Storage::make($file)->save( public_path('/storage/loonstrookjes/' . $filename) );
}
return Payment::create([
'file_name' => $filename,
'file_path' => '/storage/loonstrookjes/',
'user_id' => $request->type
]);
return route('fileupload.create');
}
}
View Changes:
form action="{{ route('File.store') }}"

Laravel won't register user in Users Table

I am trying to work on a Laravel PHP project and as I am new to this framework. First step I had to do is build a Registration Form. However, when I click on the Submit button no error is given, and nothing is registered in my users table.
Here is the code for my project so far :
My users migration table up and down functions
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->boolean('sexe');
$table->integer('age');
$table->string('name');
$table->string('email')->unique();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
}
public function down()
{
Schema::dropIfExists('users');
}
I added to the original two fields which are : "sexe a boolean F/M" and age
My RegisterController important functions
<?php
namespace App\Http\Controllers;
use App\User;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;
use Illuminate\Foundation\Auth\RegistersUsers;
use Illuminate\Http\Request;
use Mail;
class RegisterController extends Controller
{
use RegistersUsers;
protected $redirectTo = '/register';
public function __construct()
{
$this->middleware('guest');
}
protected function validator(array $data)
{
return Validator::make($data, [
'name' => 'required', 'string', 'max:255',
'sexe'=> 'required|in:male,female',
'age' => 'required|integer|max:100',
'email' => 'required', 'string', 'email', 'max:255', 'unique:users',
'password' => 'required', 'string', 'min:5', 'confirmed',
]);
}
protected function create(array $data)
{
return User::create([
'name' => $data['name'],
'sexe' => $data['sexe'],
'age' => $data['age'],
'email' => $data['email'],
'password' => Hash::make($data['password']),
]);
}
/**
* Override default register method from RegistersUsers trait
*
* #param array $request
* #return redirect to $redirectTo
*/
public function register(Request $request)
{
$this->validator($request->all())->validate();
//add activation_key to the $request array
$activation_key = $this->getToken();
$request->request->add(['activation_key' => $activation_key]);
$user = $this->create($request->all());
//$this->guard()->login($user);
//write a code for send email to a user with activation link
$data = array('name' => $request['name'], 'email' => $request['email'], 'activation_link' => url('/activation/' . $activation_key));
Mail::send('emails.mail', $data, function($message) use ($data) {
$message->to($data['email'])
->subject('Activate Your Account');
$message->from('s.sajid#artisansweb.net');
});
return $this->registered($request, $user)
?: redirect($this->redirectPath())->with('success', 'We have sent an activation link on your email id. Please verify your account.');
print_r($request->input());
}
}
My Routes
Route::auth();
Route::get('/home', 'HomeController#index');
Auth::routes();
Route::get('/register', 'RegisterController#create');
Route::post('/register', 'RegisterController#register');
Route::get('/', function () {
return view('welcome');
});
My User.php Model fillable
protected $fillable = [
'name','sexe','age','email','password',
];
protected $hidden = [
'password', 'remember_token',
];
public function setPasswordAttribute($password)
{
$this->attributes['password'] = bcrypt($password);
}
}
My blade file register part (register.blade.php)
<body>
<form method="POST" role="form" action="//IJJI/resources/views/chat.blade.php">
<meta name="csrf-token" content="{{ csrf_token() }}">
<input id="name" name="name"type="text" class="form-control" placeholder="Entrez ici votre Pseudo *" value="" />
<label class="radio inline">
<input id="homme" type="radio" name="sexe" value="homme" checked>
<span> Homme </span>
</label>
<label class="radio inline">
<input id="femme" type="radio" name="sexe" value="femme">
<span>Femme </span>
</label>
<input id="age" name="age" type="integer" class="form-control" placeholder="Saisissez votre age *" value="" />
<input id="Email" name="email" type="email" class="form-control" placeholder="Saisissez votre Email *" value="" />
<input id="password" name="password" type="password" class="form-control" placeholder="Entrez votre Mot de Passe *" value="" />
<input id="confirmpassword" name="confirmpassword" type="password" class="form-control" placeholder="Confrimez votre Mot de Passe *" value="" />
<button type="submit" class="btnRegister">
Je deviens membre Gratuitement
</button>
</form>
</body>
I have done PHP artisan make auth generated the files, made .env file adequate to my MySQL database with the username and password, even checked the PhpMyAdmin configuration, but all in vain.
After 4 days of search in Google websites I can't figure out where I am wrong.
P.S : Another thing that could be wrong is that code like this :
#section
#endsection
never gets accepted and just shows like normal text on my browser.
Thanks a lot for your help
Check your laravel logs location: storage/logs you will get errors.
i have notice you are using $table->boolean('sexe') and in validation you are giving string boolen should be 0/1
'sexe'=> 'required:in:true,false',
also change in your html form to 0,1 currently you are using male, female
Are you getting error?
Besides, can you please the following line at the top of your form to see if there is any validation error or not. After that try submitting the form and see if there is any error or not!
#if(count($errors) > 0)
<div style="color:red">
#foreach ($errors->all() as $message)
<ul>
<li>{{$message}}</li>
</ul>
#endforeach
</div>
#endif
And remove the action form the form tags.
Use:
#csrf
or
{{csrf_field()}}
instead of
<meta name="csrf-token" content="{{ csrf_token() }}">

Laravel - Register don't send data to database

I'm on Laravel 5.4 and i'm trying to do a register page but data are not send in my databse... And i don't have any error.
Here is the controller : (Generate by Laravel)
namespace App\Http\Controllers\Auth;
use App\User;
use App\PostUser;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Validator;
use Illuminate\Foundation\Auth\RegistersUsers;
class RegisterController extends Controller
{
protected $primaryKey = "id_biodiv_acteur";
protected $table = "acteur";
use RegistersUsers;
protected $redirectTo = '/pages/users';
public function __construct()
{
$this->middleware('guest');
}
protected function validator(array $data)
{
return Validator::make($data, [
'name' => 'required|string|max:255',
'surname' => 'string|max:255',
...
'picture' => 'image'
]);
}
protected function create(array $data)
{
return User::create([
'nom' => $data['name'],
'prenom' => $data['surname'],
...
'image' => $data['picture']
]);
}
}
My register.blade.php :
<div class="add-content container">
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<h1>• Ajouter un utilisateur •</h1>
<div class="underline"></div>
<form action="{!! route('register') !!}" accept-charset="UTF-8" method="post" role="form">
{!! csrf_field() !!}
<div class="column-left">
<label class="has-float-label" for="name">
<input class="" type="text" placeholder="" name="name" required>
<span>Nom</span>
</label>
<label class="has-float-label" for="password">
<input class="" type="password" placeholder="" name="password" required>
<span>Mot de passe</span>
</label>
...
<label class="has-float-label" for="picture">
<input type="file" name="picture" multiple>
<span>Ajoutez des images</span>
</label>
</div>
<button type="submit" name="button">Enregistrer</button>
</form>
</div>
And a model i added to the controller (PostUser.php) :
use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Auth\Events\Registered;
class PostUser extends Model
{
public $timestamps = false;
protected $primaryKey = "id_acteur";
protected $table = "acteur";
protected $fillable = [
'nom',
'prenom',
...
'image'
];
}
Laravel created route for register :
$this->get('register', 'Auth\RegisterController#showRegistrationForm')->name('register');
$this->post('register', 'Auth\RegisterController#register');
But i haven't any function call register or showRegistrationForm in RegisterController
If route('register') goes to RegisterController#create method, you can get the user-entered data in the Request parameter of that method:
protected function create(\Illuminate\Http\Request $request)
{
return User::create([
'nom' => $request->name,
'prenom' => $request->surname,
...
'image' => $request->picture
]);
}
Also, as mentioned in comments, you need to change User to PostUser or vice-versa.

Categories