# laravel request & response ###### tags: `laravel` ### 移除request的特定input https://stackoverflow.com/questions/35327679/validate-or-remove-for-extra-fields-in-laravel ```php! if(!$request->input('img')==null){ $request->request->remove('img'); } ``` ### (laravel5.8)如何針對不同request回傳不同response https://stackoverflow.com/questions/42815196/how-to-return-different-output-formats-from-the-same-controller-method-in-larave ```php <?php namespace App\Http\Controllers; use Illuminate\Http\Request; use App\Models\Todo; class TodosController extends Controller { //... public function show($id, Request $req) { $todo = Todo::find($id); // If the request has header `Accept: */json`, return JSON if ($req->wantsJson()) { return $todo; } // Otherwise, return view return view('show', ['todo' => $todo]); } //... } ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up