Category : rest

Laravel usually use following for request validation. $request->validate([ ‘name’ => [‘required’, ‘string’, ‘max:255′], ’email’ => [‘required’, ‘string’, ’email’, ‘max:255’, ‘unique:users’, ‘required_without_all:phone’], ‘password’ => [‘required’, ‘confirmed’, RulesPassword::defaults()], ‘phone’ => [‘required’, ‘string’, ‘max:13’, ‘unique:users’, ‘required_without_all:email’], ]); This method only add $error variable that can be access using blade files as it render on server only. But now ..

Read more

Laravel usually use following for request validation. $request->validate([ ‘name’ => [‘required’, ‘string’, ‘max:255′], ’email’ => [‘required’, ‘string’, ’email’, ‘max:255’, ‘unique:users’, ‘required_without_all:phone’], ‘password’ => [‘required’, ‘confirmed’, RulesPassword::defaults()], ‘phone’ => [‘required’, ‘string’, ‘max:13’, ‘unique:users’, ‘required_without_all:email’], ]); This method only add $error variable that can be access using blade files as it render on server only. But now ..

Read more

I am developing REST APIs for my project in Laravel 6.*. The problem is that my APIs are working in Postman Chrome Extention and web browser but not in Native Desktop Application. I’m am serving my laravel app. by using php artisan serve command. the The error which i got in postman console Sourc..

Read more

I am building a Laravel application with a Vue front end and Laravel API back end. I have been following REST guidelines and have created the following end points for retrieving documents: // Documents Route::prefix(‘documents’)->name(‘documents.’)->group(function () { Route::get(‘/’, [DocumentController::class, ‘index’])->name(‘index’); Route::get(‘/{document}’, [DocumentController::class, ‘show’])->name(‘show’); Route::post(‘/’, [DocumentController::class, ‘store’])->name(‘store’); Route::put(‘/{document}’, [DocumentController::class, ‘update’])->name(‘update’); Route::delete(‘/{document}’, [DocumentController::class, ‘delete’])->name(‘delete’); }); The documents ..

Read more

I want to get a JSON response when there is already a user existing with the same email id. public function register(Request $request) { $user = new User(); $user->name = $request->input(‘name’); $user->email = $request->input(’email’); $user->password = Hash::make($request->input(‘password’)); if($user->save()){ if (Auth::attempt([’email’ => $request->input(’email’), ‘password’ => $request->input(‘password’)])) { return response([‘result’ => true, ‘user’ => Auth::user()]); } } ..

Read more

I am trying to send POST request to restful API using GuzzleHttp from laravel on nginx server. But I have 502 bad gateway. My code is as below: $from_date = Carbon::today()->format(‘Y-m-d’); $to_date = Carbon::today()->format(‘Y-m-d’); $domain = "abc.vn"; $key = "keyacbxyz"; $client = new Client(); $response = $client->post(‘http://exampleurl.com’, [ ‘json’ => [ ‘fromdate’ => $from_date, ‘todate’ ..

Read more

I’m developing rest api in laravel, here im trying to post array data in database, but i could not figure out how to do it, can some one guide me in this ? i’m new to laravel ProductdetaisController.php <?php namespace AppHttpControllers; use IlluminateHttpRequest; use AppModelsproductdetails; class ProductdetailsController extends Controller{ /** * Display a listing of ..

Read more