Last active
January 8, 2020 05:28
-
-
Save moradi-morteza/49044b537525d164606a2be162e5e895 to your computer and use it in GitHub Desktop.
[request] #LaravelT
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Request $request | |
You may also retrieve all of the input data as an array using the all method: | |
//$request->all() : return its data for post method in array type | |
//$request->all() : return its data for get method in query string like : http://127.0.0.1:8000/admin/products?name=ali in array | |
// how to get data from Request | |
Route::get('/test',function (Request $request){ | |
$server =$request->server; | |
dd($server->get('DOCUMENT_ROOT')); | |
}); | |
//------------------------------------------------ | |
Route::post('/send','MyController@index'); | |
// send json with insomnia | |
{ | |
"name":"ali", | |
"age":25, | |
"profile_image":(file), | |
"passport_iamge":(file) | |
} | |
public function store(Request $request) | |
{ | |
// get all file | |
$files=$request->files; | |
// get single file | |
$profile=$request->('profile_image'); | |
$address_of_upload_place=$request->('profile_image')->path(); | |
$original_name=$request->('profile_image')->getClientOriginalName(); | |
//for save file : | |
$request->('profile_image')-storeAs($save_path); | |
$name = $request->name; | |
$age = $request->get('age',34); // if age not set by default its 34 | |
// check set | |
if(isset('name')){return 'yes';} | |
return $request->has('age') ? 'yes' : 'no'; | |
//cookie and token | |
$request->cookies; | |
// it has (XSRF-TOKEN and laravel_session) for get certain of then use : | |
$request->cookie('XSRF-TOKEN') | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment