laravel 5.2 登録フォームにプロフィール写真をアップロードするのを手伝ってください。登録とログインに Auth を使用していますが、いくつかの変更を加えました。
これは私の register.blade.php ビューです
@extends('layouts.app')
@section('content')
<div class="container">
<div class="row">
<div class="col-md-8 col-md-offset-2">
<div class="panel panel-primary">
<div class="panel-heading">Pendaftaran Akun Baru</div>
<div class="panel-body">
<form class="form-horizontal" role="form" method="POST" action="{{ url('/register') }}">
{!! csrf_field() !!}
<!-- start of nip -->
<div class="form-group{{ $errors->has('nip') ? ' has-error' : '' }}">
<label class="col-md-4 control-label">Nomor Induk Pegawai</label>
<div class="col-md-6">
<input type="text" class="form-control" name="nip" value="{{ old('nip') }}">
@if ($errors->has('nip'))
<span class="help-block">
<strong>{{ $errors->first('nip') }}</strong>
</span>
@endif
</div>
</div>
<!-- end of nip -->
<!-- start of nama -->
<div class="form-group{{ $errors->has('nama') ? ' has-error' : '' }}">
<label class="col-md-4 control-label">Nama</label>
<div class="col-md-6">
<input type="text" class="form-control" name="nama" value="{{ old('nama') }}">
@if ($errors->has('nama'))
<span class="help-block">
<strong>{{ $errors->first('nama') }}</strong>
</span>
@endif
</div>
</div>
<!-- end of nama -->
<!-- start of email -->
<div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}">
<label class="col-md-4 control-label">Alamat E-mail</label>
<div class="col-md-6">
<input type="email" class="form-control" name="email" value="{{ old('email') }}">
@if ($errors->has('email'))
<span class="help-block">
<strong>{{ $errors->first('email') }}</strong>
</span>
@endif
</div>
</div>
<!-- end of email -->
<!-- start of password -->
<div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}">
<label class="col-md-4 control-label">Password</label>
<div class="col-md-6">
<input type="password" class="form-control" name="password">
@if ($errors->has('password'))
<span class="help-block">
<strong>{{ $errors->first('password') }}</strong>
</span>
@endif
</div>
</div>
<!-- end of password -->
<!-- start of konfirmasi -->
<div class="form-group{{ $errors->has('password_confirmation') ? ' has-error' : '' }}">
<label class="col-md-4 control-label">Konfirmasi Password</label>
<div class="col-md-6">
<input type="password" class="form-control" name="password_confirmation">
@if ($errors->has('password_confirmation'))
<span class="help-block">
<strong>{{ $errors->first('password_confirmation') }}</strong>
</span>
@endif
</div>
</div>
<!-- end of konfirmasi -->
<!-- start of foto -->
<div class="form-group{{ $errors->has('avatar') ? ' has-error' : '' }}">
<label class="col-md-4 control-label">F o t o</label>
<div class="col-md-6">
<div id="kv-avatar-errors" class="center-block" style="width:800px;display:none">
</div>
<div class="kv-avatar" style="width:200px">
<input id="avatar" name="avatar" type="file" class="file-loading">
</div>
</div>
</div>
<!-- end of foto -->
<div class="form-group">
<div class="col-md-6 col-md-offset-4">
<button type="submit" class="btn btn-primary">
<i class="fa fa-btn fa-user"></i>Daftar
</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
@endsection
これは私の雄弁な app\Daftarpegawai.php です
<?php
namespace App;
use Illuminate\Foundation\Auth\User as Authenticatable;
class Daftarpegawai extends Authenticatable {
protected $fillable = [
'nip', 'nama', 'email', 'password', 'foto',
];
protected $hidden = [
'password', 'status', 'remember_token',
];
}
これは私のAuthController.phpです
<?php
namespace App\Http\Controllers\Auth;
use App\Daftarpegawai;
use Validator;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\ThrottlesLogins;
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
class AuthController extends Controller
{
use AuthenticatesAndRegistersUsers, ThrottlesLogins;
protected $redirectTo = '/';
public function __construct()
{
$this->middleware($this->guestMiddleware(), ['except' => 'logout']);
}
protected function validator(array $data)
{
return Validator::make($data, [
'nip' => 'required|max:20',
'nama' => 'required|max:255',
'avatar' => 'mimes:jpg',
'email' => 'required|email|max:255|unique:daftarpegawais',
'password' => 'required|confirmed|min:6',
]);
}
protected function create(array $data)
{
return Daftarpegawai::create([
'nip' => $data['nip'],
'nama' => $data['nama'],
'foto' => $data['avatar'],
'email' => $data['email'],
'password' => bcrypt($data['password']),
]);
}
}
私はlaravelを学ぶのが初めてで、同じ問題でここで見つけたいくつかの方法を試しましたが、何もうまくいきません