create table issues ( id bigint unsigned auto_increment primary key, titles text not null, datetimes datetime not null, names text not null, category text not null, harms text not null, paths text not null, types text not null, created_at timestamp null, updated_at timestamp null ) collate = utf8mb4_unicode_ci;
classPostControllerextendsController { /** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ publicfunctionindex() { // }
/** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ publicfunctioncreate(Request $request) { $user = newUser(); $user->name='test_name'; $user->email='test_email'; $user->password='test_password'; $user->save(); }
classPostControllerextendsController { /** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ publicfunctionindex() { // }
/** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ publicfunctioncreate(Request $request) { $Tessts = newTesst(); $Tessts->name='test_namess'; $Tessts->email='test_emailss'; $Tessts->password='test_passwordss'; $Tessts->save(); }
classPostControllerextendsController { /** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ publicfunctionindex() { // }
/** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ publicfunctioncreate(Request $request) { $Tessts = newTesst(); $Tessts->name= $request->input('user'); $Tessts->email= $request->input('email'); $Tessts->password= $request->input('password'); $Tessts->save(); }
/* |-------------------------------------------------------------------------- | 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! | */ useIlluminate\Http\Request;
Route::get('/', function () { returnview('welcome'); });
Route::get('/input', function () { returnview(('input')); });
classPostControllerextendsController { /** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ publicfunctionindex() { // }
/** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ publicfunctioncreate(Request $request) { $Tessts = newTesst(); Tesst::find($request->input('id'))->delete();//按主键删除 $Tessts->forceDelete(); }
classPostControllerextendsController { /** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ publicfunctionindex() { // }
/** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ publicfunctioncreate(Request $request) { $Tessts = Tesst::find($request->input('id')); $Tessts->name=$request->input('name'); $Tessts->save(); }
<?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!
|
*/
Route::get('/input/test', 'PostController@create');
/* |-------------------------------------------------------------------------- | Mail Driver |-------------------------------------------------------------------------- | | Laravel supports both SMTP and PHP's "mail" function as drivers for the | sending of e-mail. You may specify which one you're using throughout | your application here. By default, Laravel is setup for SMTP mail. | | Supported: "smtp", "sendmail", "mailgun", "ses", | "postmark", "log", "array" | */
'driver' => env('MAIL_DRIVER', 'smtp'),
/* |-------------------------------------------------------------------------- | SMTP Host Address |-------------------------------------------------------------------------- | | Here you may provide the host address of the SMTP server used by your | applications. A default option is provided that is compatible with | the Mailgun mail service which will provide reliable deliveries. | */
'host' => env('MAIL_HOST', 'smtp.ym.163.com'),
/* |-------------------------------------------------------------------------- | SMTP Host Port |-------------------------------------------------------------------------- | | This is the SMTP port used by your application to deliver e-mails to | users of the application. Like the host we have set this value to | stay compatible with the Mailgun e-mail application by default. | */
'port' => env('MAIL_PORT', 25),
/* |-------------------------------------------------------------------------- | Global "From" Address |-------------------------------------------------------------------------- | | You may wish for all e-mails sent by your application to be sent from | the same address. Here, you may specify a name and address that is | used globally for all e-mails that are sent by your application. | */
/* |-------------------------------------------------------------------------- | E-Mail Encryption Protocol |-------------------------------------------------------------------------- | | Here you may specify the encryption protocol that should be used when | the application send e-mail messages. A sensible default using the | transport layer security protocol should provide great security. | */
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
/* |-------------------------------------------------------------------------- | SMTP Server Username |-------------------------------------------------------------------------- | | If your SMTP server requires a username for authentication, you should | set it here. This will get used to authenticate with your server on | connection. You may also set the "password" value below this one. | */
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
/* |-------------------------------------------------------------------------- | Sendmail System Path |-------------------------------------------------------------------------- | | When using the "sendmail" driver to send e-mails, we will need to know | the path to where Sendmail lives on this server. A default path has | been provided here, which will work well on most of your systems. | */
'sendmail' => '/usr/sbin/sendmail -bs',
/* |-------------------------------------------------------------------------- | Markdown Mail Settings |-------------------------------------------------------------------------- | | If you are using Markdown based email rendering, you may configure your | theme and component paths here, allowing you to customize the design | of the emails. Or, you may simply stick with the Laravel defaults! | */
/* |-------------------------------------------------------------------------- | Log Channel |-------------------------------------------------------------------------- | | If you are using the "log" driver, you may specify the logging channel | if you prefer to keep mail messages separate from other log entries | for simpler reading. Otherwise, the default channel will be used. | */
// Here we will attempt to reset the user's password. If it is successful we // will update the password on an actual user model and persist it to the // database. Otherwise we will parse the error and return the response. $response = $this->broker()->reset( $this->credentials($request), function ($user, $password) { $this->resetPassword($user, $password); } );
// If the password was successfully reset, we will redirect the user back to // the application's home authenticated view. If there is an error we can // redirect them back to where they came from with their error message. return$response == Password::PASSWORD_RESET ? $this->sendResetResponse($request, $response) : $this->sendResetFailedResponse($request, $response); }
/** * Get the response for a successful password reset. * * @param \Illuminate\Http\Request $request * @param string $response * @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\JsonResponse */ protectedfunctionsendResetResponse(Request $request, $response) { returnredirect($this->redirectPath()) ->with('status', trans($response)); }
/** * Get the response for a failed password reset. * * @param \Illuminate\Http\Request $request * @param string $response * @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\JsonResponse */ protectedfunctionsendResetFailedResponse(Request $request, $response) { returnredirect()->back() ->withInput($request->only('email')) ->withErrors(['email' => trans($response)]); }
/** * Get the broker to be used during password reset. * * @return \Illuminate\Contracts\Auth\PasswordBroker */ publicfunctionbroker() { returnPassword::broker(); }
/** * Get the guard to be used during password reset. * * @return \Illuminate\Contracts\Auth\StatefulGuard */ protectedfunctionguard() { returnAuth::guard(); } }
classRegisterControllerextendsController { /* |-------------------------------------------------------------------------- | 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. | */
useRegistersUsers;
/** * Where to redirect users after registration. * * @var string */ protected$redirectTo = '/home';
/** * Create a new controller instance. * * @return void */ publicfunction__construct() { $this->middleware('guest'); }
/** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ publicfunctioncreate(Request $request) { $id = $request->input('id'); DB::insert('insert into user(id) value(?)', [$id]); }
/* |-------------------------------------------------------------------------- | 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! | */ useIlluminate\Http\Request;
Route::get('/', function () { returnview('welcome'); });
Route::get('/input', function () { returnview(('input')); });
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ publicfunctiondestroy(Request $request) { $id = $request->input('id'); DB::delete('delete from user where id = ?',[$id]); }
/** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ publicfunctionedit(Request $request) { $id = $request->input('id'); DB::update('update user set id=?',[$id]); }
/* |-------------------------------------------------------------------------- | 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! | */ useIlluminate\Http\Request;
Route::get('/', function () { returnview('welcome'); });
Route::get('/input', function () { returnview(('input')); });
Route::post('/input/test', function (Request $request) { if ($request->isMethod('post')) { echo"yes"; } else { echo"no"; } });
/* |-------------------------------------------------------------------------- | 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! | */ useIlluminate\Http\Request;
Route::get('/', function () { returnview('welcome'); });
Route::get('/input', function () { returnview(('input')); });
classStoreTestPostextendsFormRequest { /** * 确定用户是否有权提出此请求。 * Determine if the user is authorized to make this request. * * @return bool */ publicfunctionauthorize() { returntrue; }
/** * 获取应用于请求的验证规则。 * Get the validation rules that apply to the request. * * @return array */ publicfunctionrules() { return [ 'test' => 'required', ]; }
/* * 为规则写入提示信息 * Write prompt information for rules */ publicfunctionmessages() { return [ 'required' => ':attribute必填', ]; }
/* * 为表单设置名称 * Set a name for the form */ publicfunctionattributes() { return [ 'test' => "测试", ]; } }
需要注意的是我们还需要修改当前的控制器,将请求改为表单请求:
1 2 3 4 5 6 7 8 9 10
/** * Store a newly created resource in storage. * * @param StoreTestPost $request * @return \Illuminate\Http\Response */ publicfunctionstore(StoreTestPost $request) { // }
/* |-------------------------------------------------------------------------- | 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! | */ useIlluminate\Http\Request;
Route::get('/', function () { returnview('welcome'); });
Route::get('/url', function (Request $request) { $session = $request->session()->all(); print_r($session); });
/* |-------------------------------------------------------------------------- | 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! | */ useIlluminate\Http\Request;
Route::get('/', function () { returnview('welcome'); });
/* |-------------------------------------------------------------------------- | 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! | */ useIlluminate\Http\Request;
Route::get('/', function () { returnview('welcome'); });
/* |-------------------------------------------------------------------------- | 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! | */ useIlluminate\Http\Request;
Route::get('/', function () { returnview('welcome'); });
Route::get('/url', function (Request $request) { // 存储 $request->session()->put('jiangxue','Jiang Xue analyzes the open knowledge repository'); session(['key'=>'value']);
/* |-------------------------------------------------------------------------- | 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! | */ useIlluminate\Http\Request;
Route::get('/', function () { returnview('welcome'); });
Route::get('/url', function (Request $request) { // 存储 $request->session()->flash('jiangxue','Jiang Xue analyzes the open knowledge repository'); session(['key'=>'value']);
Route::get('/url', function (Request $request) { // 存储 $request->session()->put('jiangxue','Jiang Xue analyzes the open knowledge repository'); session(['key'=>'value']);
/* |-------------------------------------------------------------------------- | 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! | */ useIlluminate\Support\Facades\View;
Route::get('/', function () { returnview('welcome'); });
Route::get('/url/{name}', function ($name) { echourl()->current(); });
/* |-------------------------------------------------------------------------- | 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! | */ use Illuminate\Support\Facades\View;
Route::get('/', function () { return view('welcome'); });
Route::get('/url/{name}', function ($name) { echo url()->previous(); });
/* |-------------------------------------------------------------------------- | 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! | */ useIlluminate\Support\Facades\URL;
Route::get('/', function () { returnview('welcome'); });
/* |-------------------------------------------------------------------------- | 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! | */
Route::get('/', function () { returnview('welcome'); });
Route::get('/views/{name}', function ($name) { returnview('views', ['name' => $name]); });
views.blade.php
1 2 3 4 5 6 7 8
<html> <head> <title>This is be Input up</title> </head> <body> <h1>Hello,{{$name}}</h1> </body> </html>