本文介绍了Laravel关于请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是laravel编程的新手.所以在这里我不会问我的问题,但是我在这里只是想问一下如何使用laravel.在这里我想问一下如何使用:

i am new in programing laravel. so here I will not ask about my problems but I am here just want to ask how to use laravel. here I would like to ask how to use:

确定laravel中是否存在输入值.及其作用?

Determining If an Input Value Is Present in laravel. and what it does?

感谢^^

推荐答案

Laravel确实是一个很好的MVC框架.我可以为您提供一些资料,从那里您可以更好地了解Laravel框架.

Laravel is really a good MVC Framework. I can suggest you some source from where you can get better understanding of Laravel Framework.

  1. https://laravel.com/docs/5.2
  2. https://laracasts.com/skills/laravel
  1. https://laravel.com/docs/5.2
  2. https://laracasts.com/skills/laravel

举个简单的例子-安装后如何使用Laravel

For simple example - How to use Laravel after installation

  • 使用终端ex转到路径. /var/www/laravel/project
  • 转到-/var/www/laravel/project/resources/views
  • 创建目录测试并创建文件index.php
  • 创建控制器-php artisan make:controller TestController
  • 创建一个函数testGet()并返回视图-return view('test.index');//test是目录,索引是文件
  • 创建一个函数testPost(Request $request),并使用$data = $request->all();获取数据,然后打印此数据.
  • 使用迁移文件创建模型-php artisan make:model Test --migration
  • 转到路由文件-/var/www/laravel/project/app/Http/routes.php
  • 添加行Route::get('/test', 'TestController@testGet');
  • 添加行Route::post('/test', 'TestController@testPost');
  • Go to path using terminal ex. /var/www/laravel/project
  • Go to - /var/www/laravel/project/resources/views
  • Create a directory test and create a file index.php
  • Create a controller - php artisan make:controller TestController
  • Create a function testGet() and return view - return view('test.index'); //test is directory and index is file
  • Create a function testPost(Request $request) and to get data use $data = $request->all(); and then print this data.
  • Create a model with migration file - php artisan make:model Test --migration
  • Go to route file - /var/www/laravel/project/app/Http/routes.php
  • Add line Route::get('/test', 'TestController@testGet');
  • Add line Route::post('/test', 'TestController@testPost');

现在检查对您的项目 http://project/test 的GET请求,它将调用testGet函数.POST请求 http://project/test?name = Adam 将调用testPost函数并打印您的姓名.

Now check GET request to your project http://project/test it will call testGet function.POST request http://project/test?name=Adam will call testPost function and will print your name.

这篇关于Laravel关于请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-31 13:24