nafeeur10

nafeeur10

Member Since 2 Years Ago

Experience Points
12,990
Total
Experience

2,010 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed
28
Lessons
Completed
Best Reply Awards
2
Best Reply
Awards
  • start your engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-in-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

Level 3
12,990 XP
Aug
12
3 days ago
Activity icon

Replied to Column Not Found: 1054 Unknown Column '0' In 'where Clause'

@michaloravec You are the BEST Answer. I remembered your FIRST ANSWER. so didn't give Best Answer. However...........................

Activity icon

Replied to Column Not Found: 1054 Unknown Column '0' In 'where Clause'

@sinnbeck and @michaloravec both are Best Answer. But I think @sinnbeck answer is better to me. :-)

Activity icon

Replied to Column Not Found: 1054 Unknown Column '0' In 'where Clause'

@sinnbeck ,

Giving me Success but not updating my data!!!

Activity icon

Replied to Column Not Found: 1054 Unknown Column '0' In 'where Clause'

After that data is not updating!!!!!

try {

            $clientId = Auth::id();
            $idOftheRow = $request->id;
            $this->validate($request, [
                'name' => 'required',
                'image' => 'required',
                'email' => 'required',
                'phone_number' => 'required',
                'email' => ['required', 'email', Rule::unique('instructors')->where(function ($query) use ($clientId, $idOftheRow) {
                    $query->where('client_id', $clientId)->where('id', '<>', $idOftheRow);
                })],
            ]);


            //$data = $request->Instructor;

            $instructor = Instructor::find($request->id);
            $instructor->name = $request->name;
            $instructor->image = $request->image;
            $instructor->email = $request->email;
            $instructor->phone_number = $request->phone_number;
            $instructor->client_id = Auth::id();
            $instructor->save();
            return response()->json([
                'status' => 'success',
                'message' => 'Instructor Updated Successfully!'
            ]);

        } catch(ValidationException $exception) {
            return response()->json([
                'status' => 'error',
                'errors' => $exception->errors()
            ]);
        }
Activity icon

Started a new Conversation Column Not Found: 1054 Unknown Column '0' In 'where Clause'

I am trying to validate my data during update. A client will not be able to insert save email in the table and it will just check in the other field except his own..

$clientId = Auth::id();
$idOftheRow = $request->id;
$this->validate($request, [
        'name' => 'required',
        'image' => 'required',
        'email' => 'required',
        'phone_number' => 'required',
        'email' => ['required', 'email', Rule::unique('instructors')->where(function ($query) use ($clientId, $idOftheRow) {
             $query->where(
               ['client_id', '=', $clientId],
              ['id', '<>', $idOftheRow]
             );
      })],
]);

Giving me the above error. What is the problem with my Query?

Aug
10
5 days ago
Activity icon

Started a new Conversation How To Validate Two Combined Unique Column In Laravel Controller

What I want:

I have multiple Client. One client has multiple Customers. One customer can be customer of multiple Clients.

But one Client can't add same email

Suppose,

----------------------------------------------------------
Client ID                         Customer Email
----------------------------------------------------------
1.                                   [email protected]
2.                                   [email protected]
----------------------------------------------------------

But Client 1 will not be able to add again [email protected]

In my migration file, I gave them two columns in unique

Schema::create('customers', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('email');
            $table->integer('client_id');
            $table->unique(['client_id', 'email']);
            $table->timestamps();
 });

It is working.

But how will I validate this in Controller?

I have tried like this:

$this->validate($request, [
        'email' => 'required|email|unique:customers',
]);

But it is just checking the Email is Unique

How can I do that?

Activity icon

Replied to V-slot:no-data Is Not Showing Anything!

@bobbybouwmann,

But I don't know why my Table Header is absent and The message of NO Data is.

While NO DATA. There is no HEADER and Message also.

<v-data-table 
                    class="elevation-1"
                    :headers="customerHeaders"
                    :items="customers"
                    :footer-props="{
                      'items-per-page-options': [5, 10, 20, 25, 30, 40, 50, 100, -1]
                    }"
                    :items-per-page="25"
                    :loading = loader
                  >
                  <template v-slot:item.actions="{ item }">
                      <v-icon
                        small
                        class="mr-2"
                        @click="editItem(item)"
                      >
                        mdi-pencil
                      </v-icon>
                      <v-icon
                        small
                        @click="deleteItem(item)"
                      >
                        mdi-delete
                      </v-icon>
                  </template>

                  <template v-slot:no-data>
                    <v-btn color="primary" @click="initialize">Reset</v-btn>
                  </template>


</v-data-table>

Data Properties:

customerHeaders: [
          {
            text: 'Customer Name',
            value: 'customer_name',
          },
          { text: 'Company Name', value: 'company_name' },
          { text: 'Address', value: 'address' },
          { text: 'Email', value: 'email' },
          { text: 'Phone', value: 'phone' },
          { text: 'Actions', value: 'actions' },
],
customers: []

Strange Problem!!!

Aug
09
6 days ago
Activity icon

Started a new Conversation V-slot:no-data Is Not Showing Anything!

<template v-if="customers != null && customers.length > 0">
      <v-data-table 
          class="mb-4"
          :headers="customerHeaders"
          :items="customers"
          :items-per-page="15"
          :loading = loader
      >
      <template v-slot:no-data>
          <p>The Table is Empty. Please insert data with the above Button.</p>
      </template>
     </v-data-table>
</template>

While table is empty v-slot:no-data is not showing his message. What is the problem? There is no ERROR!

VUETIFY!

Activity icon

Replied to JSON Exception Is Taking To Login Page But Need To Show The Errors In Modal

@sinnbeck,

Console is giving me this ERROR! But taking me in Login page.

POST http://localhost:8000/api/data/user/storeCustomer 422 (Unprocessable Entity)
Activity icon

Replied to JSON Exception Is Taking To Login Page But Need To Show The Errors In Modal

use Illuminate\Validation\ValidationException;

I have import it.

And Validation is catching in Network tab.

Activity icon

Started a new Conversation JSON Exception Is Taking To Login Page But Need To Show The Errors In Modal

I am using Laravel and Vuejs. I want to Store Data in Database. I am validating my data like this:

try {
            
            $this->validate($request, [
                'customer_name' => 'required'
            ]);
    
            return response()->json([
                'status' => 'success',
                'msg'    => 'Okay',
            ], 200);
        }
        catch(ValidationException $exception) {
            return response()->json([
                'status' => 'error',
                'msg'    => 'Error',
                'errors' => $exception->errors(),
            ], 422);
        }

Exception is giving Correctly. But it's taking me to login page!!

Axios Request to do the action:

saveCustomerInDB(customer) {
        axios.post('/api/data/user/storeCustomer', 
        {
          customer_name: customer.customer_name

        }).then( (response) => {
            console.log(response);
        }).catch( (error) => {
            console.log("Error", error);
        });
 },

I just want to show the error. Not any redirection. How will I do that??

Aug
03
1 week ago
Activity icon

Started a new Conversation [Vue Warn]: Error In V-on Handler: "SyntaxError: Unexpected Token , In JSON At Position 76"

While I am trying to add this JSON data into Database then it is giving me the above Error!

var tax_setting = '{ "total_tax_settings":  { "charge_tax": ' + this.taxInfoRadioButton + 
	', "tax_settings" : [' +
	'{ "tax_name": ' + this.taxName + 
	', "tax_rate": ' + this.taxRate +
	', "tax_included_in_price": ' + this.taxIncludeInPrice + ' } ]}}';

Radio Button of this JSON:

<v-radio-group v-model="taxInfoRadioButton">
    <v-radio color="primary" label="Do not charge tax on purchases" value="1"></v-radio>
    <v-radio color="primary" label="Charge tax on purchase" value="2"></v-radio>
</v-radio-group>

data() {
  return {
     taxInfoRadioButton: '1'
  }
}

Text Field:

<v-text-field name="taxName" label="Tax Name" id="taxName" v-model="taxName"></v-text-field>
data() {
  return {
     taxName: ''
  }
}

Tax Rate is also same as above.

Select Option in JSON:

<v-select  hide-details v-bind:items="willTaxInclude"  v-model="taxIncludeInPrice"  label="Select"  single-line  menu-props="bottom" ></v-select>
data() {
  return {
     willTaxInclude: [
        { text: "Yes", value: 1 },
	{ text: "No", value: 0 }
    ],
    taxIncludeInPrice: '0',
  }
}
Aug
02
1 week ago
Activity icon

Replied to How To Store Array In DB: Array To String Conversion Error!

@sergiu17 ,

All are coming NULL in Database.

Activity icon

Started a new Conversation How To Store Array In DB: Array To String Conversion Error!

I want to store an array in my Database. But what will be the right approach?

I am trying like this:

var settings = {
	serial: 1,
	customer_payment_option: [
		cash=> this.cash,
		online=> this.online,
		bank_transfer=> this.bankTransfer
	]
}

Controller:

function save(Request $request) 
    {
        $obj= new Setting();
        $obj->setting_option_id = $request->settings['serial'];
        $obj->value = $request->settings['customer_payment_option'];

        $obj->save();

        return response()->json([
            'message' => 'Settings Added Successfully!'
        ]);
    }
Jul
30
2 weeks ago
Activity icon

Started a new Conversation Giving Me [Object Object] While Using Axios: Laravel + Vuejs

Trying to Delete an Item using Axios from Vuejs.

Axios.post('/api/data/user/deleteInstructors', {
    id: this.selectItemToDelete['id']
}).then((res) => {
   console.log('Deleted Successfully' + res);
}).catch((err) => {
    console.log("Something Wrong");
})

api.php

Route::post('/user/deleteInstructors', '[email protected]');

UserSettingController:

function deleteInstructors(Request $request) {
        return $request->all();
}
Jul
29
2 weeks ago
Activity icon

Started a new Conversation Getting [Object Object] For Axios Request.

I want to update my data with axios.

Axios.post('/api/data/user/updateInstructor', {
	id: editInstructor[index].id,
	name: editInstructor[index].name,
	email: editInstructor[index].email,
	phone_number: editInstructor[index].phone_number,
	country: editInstructor[index].country
	}).then((res)=>{
		console.log("Updated!" + res);
	}).catch((err)=>{
		console.log("Problem");
});

But while I am just return the $request it is giving me error!!

function instructorUpdate(Request $request) {
        return $request;
    }

This is giving Updated![object Object]. What is the problem?

Jul
27
2 weeks ago
Activity icon

Replied to How To Test Get Request Using Postman For Laravel API

@tykus,

You are correct. But after hitting your given url it is showing me the above Response:

"response": {
        "api_status": 0,
        "code": 400,
        "message": "Your HTTP method is not correct."
    }
Activity icon

Replied to How To Test Get Request Using Postman For Laravel API

@tykus,,

I got the URL. But it's giving me this Message in Postman:

"response": {
        "api_status": 0,
        "code": 400,
        "message": "Your HTTP method is not correct."
    }
Activity icon

Started a new Conversation How To Test Get Request Using Postman For Laravel API

I am new in Laravel API.

Route::group([
    'prefix' => 'data',
], function () {
    Route::get('stripeKeyStore', '[email protected]');
});

This is my api.php route.

public function stripeKeyStore()
{
      return "GET WORKING";
      //response()->json([$request->all()]);
}

This is the Function.

Now I am trying to Access this using Postman. But giving this Result!!!

https://ibb.co/1KLGsH6 Image of PostMan

Jul
25
3 weeks ago
Activity icon

Started a new Conversation Blocked By CORS Policy Is Not Solving! Laravel + Vuejs

Access to XMLHttpRequest at 'http://phplaravel-421708-1325291.cloudwaysapps.com/api/data/testimonials' from origin 'http://localhost:8000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

I am using Laravel and Vuejs.

Getting the above ERROR!!

I have installed this package: https://github.com/spatie/laravel-cors#laravel

I have done before "Creating your own CORS profile"

In bootstrap/app.php

I added

header('Access-Control-Allow-Origin', '*');
header('Access-Control-Allow-Methods', 'GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS');
header('Access-Control-Allow-Headers', 'Content-Type, Authorization');

But Still Problem has.... What I have to do now?

Jul
21
3 weeks ago
Activity icon

Started a new Conversation Vuex: Sidebar Is Not Toggling With The Value Of A State

I want to toggle Sidebar with a true/false value. I have stored this value in Vuex.

Like this:

state: {
        sidebartoggle: false
    },
    mutations: {
        sidebartoggle(state, item) {
            state.sidebartoggle = item
        }
}

Changing this value with a Click Event:

<i class="fas fa-shopping-cart" @click="changeSidebar"></i>

data() {
        return {
            toggle: false
        }
    },
    methods: {
        changeSidebar() {
            console.log("Cart Clicked!" + this.toggle);
            this.toggle = !this.toggle
            this.$store.commit('sidebartoggle', this.toggle)
        }
 }

Try to show the Sidebar like this:

<div id="wrapper" class="toggled" v-if="this.$store.sidebartoggle">

All are working fine. this.$store.sidebartoggle this value is giving true/false also.

What is the problem?

Activity icon

Replied to I

@aurawindsurfing,

It's not Laravel. It's Vuejs. Axios Request with API.

Activity icon

Started a new Conversation I

I am getting the error while I am trying to upload a new image. What is the problem?

Jul
15
1 month ago
Activity icon

Started a new Conversation Trying To Get Property Non-object: Laravel

return [
    'url'  => Category::where('id', $category->logo->id)->first(['slug'])->slug
]

This is giving Trying to get Property Non-Object Error.

return [
    'url'  => Category::where('id', $category->logo->id)->get(['slug'])[0]->slug
]

Then giving this error: Undefined offset: 0

How can I prevent this error. May be I can use if condition. But how?

Full Function:

$categoryIds = Collection::times(12);
   return Category::with('files')
            ->whereIn('id', $categoryIds)
            ->when($categoryIds->isNotEmpty(), function ($query) use ($categoryIds) {
                $query->orderByRaw("FIELD(id, {$categoryIds->filter()->implode(',')})");
            })
         ->get()
         ->map(function ($category) {
             return [
                  'url'  => Category::where('id', $category->logo->id)->get(['slug'])[0]->slug
        ];
});
Jul
06
1 month ago
Activity icon

Replied to How To Use Same Component For Add And Edit In Vuejs

Thank you for your reply.

How will I pass my product object from ProductList component to ProductAdd Component?

Jul
05
1 month ago
Activity icon

Started a new Conversation How To Use Same Component For Add And Edit In Vuejs

I have a Product List:

------------------------------------------
Name   |   Price   |    Actions
------------------------------------------
Apple    |  0   |   Edit / Del
Orange    |  0   |   Edit / Del
Mango    |  0   |   Edit / Del

While I will click to Edit it will go to Add Component with product object. I have product but how will I pass this to Edit Component?

I want to pass product object and isEdit boolean value.

Please give me suggestion to do that.

Jun
30
1 month ago
Activity icon

Started a new Conversation Regular Expression In Laravel

s:16:"fb.com/xyz"

I have this string.

Now I want just fb.com/xyz

How is it possible?

My try:

$str = "ignore everything except this 'text'";
$start  = strpos($str, ''');
$end    = strpos($str, ''', $start + 1);
$length = $end - $start;
$result = substr($str, $start + 1, $length - 1);
print $result;

But this code is giving error!

syntax error, unexpected '');
' (T_CONSTANT_ENCAPSED_STRING), expecting ')' 
Jun
29
1 month ago
Activity icon

Started a new Conversation Column Not Found In Laravel

Full Error:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'storefront_facebook_link' in 'field list' (SQL: select `storefront_facebook_link` from `settings`)

I am trying to get DB data from Blade. What is the problem with my code?

@php
      $facebook = \DB::table('settings')->select('storefront_facebook_link')->get();
 @endphp
Jun
21
1 month ago
Activity icon

Awarded Best Reply on Image Is Not Displaying In Laravel

I have solved it.

It will be like this:

<img class="card-img-top" src="{{ asset('images/news') }}/{{ $newssingle->news_image }}" alt="">

Thank you for your help.

Activity icon

Replied to Image Is Not Displaying In Laravel

I have solved it.

It will be like this:

<img class="card-img-top" src="{{ asset('images/news') }}/{{ $newssingle->news_image }}" alt="">

Thank you for your help.

Activity icon

Started a new Conversation Image Is Not Displaying In Laravel

I stored my images in

public/images/news/xyz.jpb

My try:

 <img class="card-img-top" src="/images/news/{{ asset($newssingle->news_image) }}" alt="">
Jun
20
1 month ago
Activity icon

Replied to 500: Internal Server Error In Laravel

@michaloravec,

Yes. Imported. But same problem. Log file means?

Activity icon

Started a new Conversation 500: Internal Server Error In Laravel

I am trying to submit a form. But giving this error! What is the problem?

Route

Route::get('/pack_details', '[email protected]_details')->name('admin.dashboard.pack_details');
Route::post('/save', '[email protected]')->name('admin.save_pack_details');

Dashboard Controller:

public function pack_details()
{
        return view('admin::dashboard.pack_details');
}

public function savepack(Request $request) 
{
       dd($request);
}

blade file:

 <form method="POST" action="{{ route('admin.save_pack_details') }}" class="form-horizontal p-5">
     {{ csrf_field() }}
     <input type="text" class="form-control mt-2" id="features11" name="features11" placeholder="Feature 1">
     <input type="submit" class="form-control d-inline-block w-25 btn-primary" id="submitbtn">
               
</form>
Jun
12
2 months ago
Activity icon

Started a new Conversation How To Use $ Sign In Vuejs

I am using Bootstrap 4 in my application. So, I need jQuery. I have installed jQuery via npm. Imported it like this:

import jQuery from 'jquery'
window.$ = window.jQuery = jQuery

But in component $ is not working!!!!

While I am import it again then working. Like below.

import $ from 'jquery'

What is the problem? How can I solve this problem??

Jun
11
2 months ago
Activity icon

Started a new Conversation FPDF Is Not Working Correctly

I am trying to write page number at the bottom of PDF. But it is showing in the Top of the page!!

<?php
	require('fpdf/fpdf.php');
	$pdf = new FPDF();

	// Position at 1.5 cm from bottom
	$pdf->SetY(-15);
	
    // Arial italic 8
	$pdf->SetFont('Arial','I',8);
	
    // Page number
    $pdf->Cell(0,10,'Page '.$pdf->PageNo().'/{nb}',0,0,'C');

	 $pdf->Output();
?>

This is the full code.

Jun
01
2 months ago
Activity icon

Replied to Code Works In Jsfiddle But Not In Localhost Or Server: Laravel 6

@deanvangreunen,

Are you working with Dropdown? Or just problem with DataTable??

Activity icon

Started a new Conversation Children But Not Sub Menu In Vue Js

-------------
   Menu
-------------

In sidebar of Admin Panel, there will be a Menu. When I will click on this Menu a page will come. That's fine.

But in this page I will also use some vue-router but they are not sub menu of that. I am trying with the below code, but not working!!!

{
    path: '/setup',
    component: Layout,
    meta: { title: 'Menu', icon: 'guide', noCache: true },
    component: () => import('@/views/custom/engage/index'),
    name: 'EngageDashboard',
    children: [
      {
        path: 'setup/domain',
        component: () => import('@/views/custom/engage/setup'),
        name: 'EngageDomain'
      }
    ]
  }

Here, while I will click on Menu' then index` page will come. In index page, there will be a button, after clicking that button setup page will come.

But now Menu is not showing

May
31
2 months ago
Activity icon

Replied to How To Protect URL In Laravel

@snapey,

Now I can understand what is my problem to think!!!!

Thank you.

Activity icon

Replied to How To Protect URL In Laravel

@michaloravec,

Can you please answer with my code??

What is the problem in my code??

Activity icon

Replied to How To Protect URL In Laravel

@michaloravec,

Okay. But Can't I do that with Middleware??

Activity icon

Started a new Conversation How To Protect URL In Laravel

I can't protect my url from one auth user to another. For Example:

www.accounting.com/user/edit/1
www.accounting.com/user/edit/2

User 1 and User 2 both are authenticated user. But hitting url they can access both!!!

I have tried with Middleware. But now page is not coming!!!!

What is the problem??

Middleware Class:

public function handle($request, Closure $next)    
{        
     if ($request->id != auth()->user()->id) {           
     return redirect('home')
            ->with('error','You are not the owner of this Page');
     return $next($request);    
}        

web.php

Route::group(['middleware' => ['auth', 'checkUser'], 'prefix' => 'admin', 'as' => 'admin.'], function () {
-----
});

If I remove 'checkUser' then page is refreshing!!!

May
19
2 months ago
Activity icon

Replied to Store And Update Button Will Work One After Another: Laravel 6

@tomasosho,

Same function for Store and Update

public function saveCost(Request $request)
{
        Incoming::where('id', $request->id)
                ->update([
                    'incoming_invoice_costs' => $request->cost,
                    'vat'                    => $request->vat
                    ]);
        return json_decode('success', 'Successfully Added Cost and VAT');
}
Activity icon

Started a new Conversation Store And Update Button Will Work One After Another: Laravel 6

I have a form like this:

----------------------------------------------------
Cost             VAT            Store-Button
----------------------------------------------------

While a user will input Cost and VAT and then click on Store-Button, then with ajax, data will sent to Database. This is working fine.

While Ajax is successful, then Store-Button will be Update Cost & VAT. If user will click on Update Cost & VAT then the form will come for update.

My problem is:

After ajax success, I can change the button with the following code:

$('form').on('submit', function(e) {
    e.preventDefault();


$.ajax({
        type: "POST",
        headers: {'x-csrf-token': _token},
        url: "{{ route('costsaving') }}",
        data: { 
            id: thenum, 
            cost: valueOfInput,
            vat: valueOfVatSelectOpt
        },
        success: function(result) {
            $("#addNewUpdateButton"+thenum).append("<button class='btn btn-info btn-xs cost-update-button' id='costandvatUpdateBtn"+thenum+"'>Update Cost & VAT</button>");
    }
)};

}

This button should submit the form. But form is not coming!! If I add this button in real, then the form is coming.

Real code, not in jquery:

 <button class="btn btn-info btn-xs cost-update-button" id="costandvatUpdateBtn{{ $incoming->id }}">Update Cost & VAT</button>

Click event of that button:

$('.cost-update-button').on('click', function(e) {
    let idOfUpdateRow = (this.id).replace(/\D/g, "");
    update = true;
});

Form:

<form method="POST">

<input type="text" id="cost{{ $incoming->id }}" data-id="{{ $incoming->id }}" name="incoming[{{ $incoming->id }}]" class="form-control shadow-none">

</form>
May
13
3 months ago
Activity icon

Replied to How To Submit Dynamic Form In Laravel With Ajax

@michaloravec,

$(this).serializeArray()[0]['name'];

with this I am getting incoming[46]

How will I extract the id from this string?!!

Activity icon

Replied to How To Submit Dynamic Form In Laravel With Ajax

@michaloravec,

Thank you for your answer. Can you tell me how will I get ID of my input field?

Activity icon

Replied to How To Submit Dynamic Form In Laravel With Ajax

@michaloravec,

Same result. Nothing is giving in console.

Activity icon

Started a new Conversation How To Submit Dynamic Form In Laravel With Ajax

I have a DataTable where I am using a Form to Submit Data.

@foreach($incomings as $key => $incoming)
<tr>
<td>
   <form method="POST" class="form-group">
        <div class="flex-row d-flex">
             <input type="text" id="{{ $incoming->id }}" class="form-control">
             <button class="btn btn-success cost-submit-button" type="submit">Store</button>
        </div>
    </form>
</td>
</tr>
@endforeach

So, you can understand it's dynamic. How will I get this dynamic form?

Trying this:

$(".cost-submit-button").click(function(e) {
    e.preventDefault();
    console.log($(this).serialize());
});

This is not giving any data!!! May I am wrong!