mercredi 2 février 2022

i am developing a website for inventory management system using laravel. I have to generate unique code for every item of the product. please help me

how can i do this? Ex- they have a product called saree its quantity is 200. so i have to generate 200 unique codes My controller looks like this..

    $this->validate($request,[
        'product_code' => 'unique:barcodes',
    ]);

    $product_code = $request->warpnumber.''.$request->subcategory.''.$request->institution;
     


  
    $generator = new Picqer\Barcode\BarcodeGeneratorHTML();
    $barcodes = 
        $generator->getBarcode($product_code,$generator::TYPE_CODE_39,1,40
    );
    

    $data = new Barcode;
    $data->product_type = $request->input('producttype');
    $data->warp= $request->input('warpnumber');
    $data->quantity= $request->input('quantity');
    $data->price= $request->input('price');
    $data->status= $request->input('status');
    $data->main_cat_id = $request->input('maincategory');
    $data->sub_cat_id = $request->input('subcategory');
    $data->institution_id = $request->input('institution'); 
    $data->barcode =  $barcodes;
    $data->product_code = $product_code;
    // $product_code = $request->warpnumber.$data->product_code;
    $data->save(); 



    return redirect()->back()->with('status','Barcode Created Successfully'); 



Aucun commentaire:

Enregistrer un commentaire