У меня есть проблема с моими маршрутами Laravel, по какому-то разуму web.php не моги находить маршрут user.signup, я вижу, что все хорошо написанное, но не получает маршрут и дает следующую ошибку: "ErrorException Use of undefined constant user - assumed 'user' (this will throw an Ошибка in в future версия of PHP)"
Это - то, что у меня есть в web.php, как они могут видеть там, - три маршрута, которые я использую, по какому-то разуму - разум signup не функционирует
<?php
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
//Invoca al controlador ProductController para que muestre el index
Route::get('/', [
'uses' => 'ProductController@getIndex',
'as' => 'product.index'
]);
Route::get('/signup', [
'uses' => 'UserController@getSignup',
'as' => 'user.signup'
]);
Route::post('/signup', [
'uses' => 'UserController@postSignup',
'as' => 'user.signup'
]);
Это - то, что у меня есть в signup.blade.php
<div class="row">
<div class="col-md-4 col-md-offset-4">
<h1>Registrarse</h1>
@if(count($errors) > 0)
<div class="alert alert-danger">
@foreach($errors->all() as $error)
<p>{{ $error }}</p>
@endforeach
</div>
@endif
<form method="post">
<div class="form group">
<label for="email">E-Mail</label>
<input type="email" id="email" name="email"></input>
</div>
<div class="form group">
<label for="password">Clave</label>
<input type="password" id="password" name="password"></input>
</div>
<button type="submit" id="submit" name="submit">Registrarse</button>
</form>
</div>
</div>
То, что у меня есть в модели User. Php
<?php
namespace App;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
class User extends Authenticatable
{
use Notifiable;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [ //Determina los datos que se pueden meter
'email', 'password',
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [ //Esconde la clave
'password', 'remember_token',
];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [
'email_verified_at' => 'datetime',
];
}
И в конце концов, это - то, что находится в драйвере, UserController.php. Поскольку они могут видеть, - методы также, что в маршрутах, но по какому-то разуму эти маршруты не функционируют, не важно, чтобы он сделал
<?php
namespace App\Http\Controllers;
use App\User;
use Illuminate\Http\Request;
use App\Http\Requests;
class UserController extends Controller
{
public function getSignup(){
return view(user.signup); //Manda al usuario al signup
}
public function postSignup(Rquest $request){
$this->validate($request, [
'email' => 'email|required|unique:users',
'password' => 'required|min:4'
]); //Valida al usuario deacuerdo si es unico y su clave es mayor a 4
$user=new User([
'email' => $request->input('email'),
'password' => bcrypt($request->input('password'))
]);
$user->save();
return redirect()->route('product.index');
}
}
В твоей линии:
return view(user.signup); //Manda al usuario al signup
ты не перемещаешь текст user.signup как цепь текста. Поэтому PHP это интерпретирует как будто о постоянной величине он относился друг к другу.
Меняет предыдущую линию из-за:
return view('user.signup'); //Manda al usuario al signup
Надеялся помочь тебе.