Category : php

how are you ? I’m using Guzzle to send post method but when i tried to send the post method with variable getting error so i tried to convert it to sting but still same this is my current code $user = Auth::user(); $mobile = $user->mobile; $client = new Client(); $booking = Booking::where(‘id’, ‘=’, e($id))->first(); ..

Read more

I’m trying to fetch some records if a certain condition is met, but am having trouble building the correct query. Here’s my example code: // $stars_selected = "4" $brokers = Broker::query() ->with(‘avgScore’); // example will returns 3.5 ->paginate(10) ->withQueryString(); Now, let’s say I have another variable present $stars_selected = "4", and I only want to ..

Read more

I’m fairly new to Laravel, but I’m trying to make a small API for my course. I’ve got this route Route::get(‘films/search’, ‘[email protected]’); which calls my custom function search which get as a parameter a Request. Here it is: public function search(Request $request) { $keyword = $request->input(‘keyword’); $rating = $request->input(‘rating’); $minLength = $request->input(‘minLength’); $maxLength = $request->input(‘maxLength’); ..

Read more

Been trying to find a way to call to pass a multidimensional array to a Post route with no success: The array looks like this: "order" => array:16 [ "id" => "1" "total" => "4825" "neighborhood" => "Barrio Bravo" ] "products" => array:2 [ 4 => array:4 [ "id" => "4" "name" => "Maestro Dobel ..

Read more

I’m new to Laravel, and would like to create a page that edits the profiles of users, including that of editing profile description, url and profile image. However, I’m getting an error that states: ‘ErrorException Attempt to read property "description" on null (View: C:xampphtdocsmyprojectnameresourcesviewsuseredit.blade.php)’ My routes in web.php are: Route::get(‘/users/{user}/edit’, [UserController::class, ‘edit’]); Route::patch(‘/users/{user}’, [UserController::class, ‘update’]); ..

Read more

I’m working on web app with php v. is 7.4.16, the laravel version is 8.31.0. When i run my FrontEnd project with global API_URL which is hosted on Linux, everything work. But when i clone the API from git-hub and run it and add LOCAL_URL in the FrontEnd i get a error like this when ..

Read more

i made a project with custom auth and it works perfectly, then i needed to integrate swoole for api socket purposes. after i added my middleware to swoole_websocket middleware swoole_websocket.php then i try to serve the swoole http, it return this error, any route under admin just keep loading till timeout i no longer can ..

Read more

html <div class="field_wrapper"> <div> <input id="size" type="text" name="size[]" value="" placeholder="Size" style="width:120px;" required="" /> <input id="sku" name="sku[]" type="text" value="" placeholder="SKU" style="width:120px;" required="" /> <input id="price" type="numver" name="price[]" value="" placeholder="Price" style="width:120px;" required="" /> <input id="stock" type="number" name="stock[]" value="" placeholder="Stock" style="width:120px;" required="" /> <a href="javascript:void(0);" class="add_button" title="Add field">add</a> </div> </div> jquery code $(document).ready(function(){ var maxField = 10; var ..

Read more

How can I fetch data along with blog category and blog tags from Blogs table using with in query. Below is my model and controller code, I am getting Get Blogs Api Error instead of the blogs data. Blog Controller public function getBlogs() { try { $blogs = Blog::where(‘status’, 1) ->with(‘category’) ->with(‘tag’) ->with(‘user’) ->with(‘comment’) ->orderBy(‘id’, ..

Read more

How can I fetch data along with blog category and blog tags from Blogs table using with in query. Below is my model and controller code, I am getting Get Blogs Api Error instead of the blogs data. Blog Controller public function getBlogs() { try { $blogs = Blog::where(‘status’, 1) ->with(‘category’) ->with(‘tag’) ->with(‘user’) ->with(‘comment’) ->orderBy(‘id’, ..

Read more

Routes Route::view(‘/{path?}’, ‘app’); Route::post("users/signup", "[email protected]"); Route::post("users/email/verify", "[email protected]"); Route::get("users/email/resend", "[email protected]"); Verify email once the user clicks on their email <?php namespace AppHttpControllers; use AppMailVerifyEmail; use AppModelsUser; use IlluminateHttpRequest; use IlluminateSupportFacadesMail; class EmailVerificationController extends Controller { public function verify( Request $request){ $user = User::where($request->input("token") ,"verification_token"); if($user){ $user->markEmailAsVerified(); $user->email_verified_at = now(); return response()->json(["msg" => "Email has been verified"]); ..

Read more

I’ve built a small web-app which listens to some webhooks from 3rd party locations and processes the data. To verify who visits my web-app, I made a simple middleware class which registeres which ip is visiting which route with which method like so: public function handle(Request $request, Closure $next) { if($request->ip() != "::1" && $request->ip() ..

Read more

I need to paginate the data which have with & wherehas condition & my query is something like below $aChefsData = Chefs::where(‘id’,$auth_id) ->addSelect(‘id’,’avatar’,’cuisine_type’) ->with(‘getFirstRestaurant’ , function ($query) use ($restaurantId, $perPage, $cPage, $mPage, $search){ $query->addSelect(‘id’,’vendor_id’) ->with(‘categories’, function ($mquery) use ($restaurantId, $perPage, $cPage, $mPage, $search){ $mquery->groupBy(‘main_category’) ->withAndWhereHas(‘menuitems’, function ($mquery) use ($restaurantId, $perPage, $mPage, $search) { $mquery->where(‘restaurant_id’,$restaurantId); if ..

Read more

I keep getting an error while migrating in Laravel. What is this error? public function up() { Schema::create(‘consultation_provider’, function (Blueprint $table) { $table->id(); $table->foreignId(‘userId’)->nullable()->constrained(‘users’)->cascadeOnDelete(); $table->foreignId(‘providerId’)->nullable()->constrained(‘users’)->cascadeOnDelete(); $table->foreignId(‘consultationId’)->constrained(‘consultations’)->cascadeOnDelete(); $table->integer(‘adequacy’, 10)->nullable(); $table->integer(‘honesty’, 10)->nullable(); $table->integer(‘good_behaviour’, 10)->nullable(); $table->timestamps(); }); } Sourc..

Read more

In my payment gateway Laravel api project. I use a lot of app()[”].As I know, it’s called service container. I know service provider, I bind payment wallets in my PaymentServiceProvider. but in this case, it’s not that complicated. I just want to store something that I can use it anywhere. For example, I store merchant ..

Read more

I’m using Semantic Versioning for my API with url paths to each version all going to the same generic endpoint. ie. I’m not prefixing /v1 or /v2 to the url’s it’s just one /url/path/to/endpoint I have middleware processing the version header the generic controller calls the appropriate Controller.Major version to handle processing. The controllers are ..

Read more