provare a creare il validatore manualmente in Lumen. La documentazione ufficiale è scritto:Classe 'Validator' non trovata in Lumen
<?php
namespace App\Http\Controllers;
use Validator;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
class PostController extends Controller
{
/**
* Store a new blog post.
*
* @param Request $request
* @return Response
*/
public function store(Request $request)
{
$validator = Validator::make($request->all(), [
'title' => 'required|unique:posts|max:255',
'body' => 'required',
]);
if ($validator->fails()) {
return redirect('post/create')
->withErrors($validator)
->withInput();
}
// Store the blog post...
}
}
ho scritto
<?php
namespace App\Http\Controllers;
use Laravel\Lumen\Routing\Controller as BaseController,
Validator;
class Welcome extends BaseController
{
public function index()
{
$validator = Validator::make(
['test' =>'TestValidation'],
['test' => 'required|unique:posts|max:255']
);
}
}
ma Lumen restituisce l'errore fatale: Fatal error: Class 'Validator' non trovato in ...
ho ha provato a fare come in Laravel 5:
use Illuminate\Support\Facades\Validator;
ma poi ritorna Lumen Fatal error: Call to make una funzione membro() su un non-oggetto in
Qualcuno sa come usare la classe Validator nella Lumen? Grazie.
la vostra risposta è giusta! Grazie! – epod
Prego! @epod – baao
Ti amo: * xoxox –