Rod2rick

Member Since 4 Months Ago

Experience Points
1,390
Total
Experience

3,610 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
0
Lessons
Completed
Best Reply Awards
0
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.

  • Community Pillar

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

Level 1
1,390 XP
Apr
01
1 week ago
Activity icon

Started a new Conversation How To Insert Multiple Data Into The Database Using A Single Query.

Hi i am new to laravel. As the title suggests, I would like to insert data into 03 tables (products, products_order, orders. Indeed, I would like

1- I want to recover the stock_products and subtract from the quantity of products to order (stock_actuel = stock_actuel - quantity)

2- In the product_commands table, we record the identifier the product identifier with the price of each product, the quantity and the total amount.

3-In the order table, we record the order information such as number, dates etc.

All this in a single store or create. here is what i did and it doesn't work.

public function commander(Request $request, $id)
    {
        // update stockproduit
        $stockproduit = Produits::find($id);
        $stockproduit['stock_actuel'] = $stockproduit['stock_actuel'] - $stockproduit['quantity'];

        $stockproduit->update($request->all());

        $commande = new RestauCommande;

        $commande->produit_id = 'cmde-' .$id;
        $produits = collect($request->produits)->transform(function ($produit) {
            $produit['total'] = $produit['quantity'] * $produit['prix'];
            return new CommandesProduits($produit);
        });
        $data = $request->except('produits');
        $data['sub_total'] = $produits->sum('total');
        $data['grand_total'] = $data['sub_total'] - $data['remise'];
        // $data['clients_id'] =  $client->id->$request->get('clients_id');

        $commande = RestauCommande::create($data);

        $commande->produits()->saveMany($produits);

        return response()
            ->json([
                'La Commande a été créée avec succès' => true,
                'id' => $commande->id,
            ]);

    }

Thank you in advance.

Mar
24
2 weeks ago
Activity icon

Replied to The Integration Of Vuejs In A Bootstrap Template Failed

As I said, the Laravel's default app.js works fine, even when I integrate<script src="{{ asset('js/app.js') }}" defer></script>. But when using my template, <script src="{{ asset('js/app.js') }}" defer></script> crashes and prevents my template from working properly. I performed in turn

php artisan ui bootstrap

php artisan ui vue.

Now at least the pages are displayed correctly, but the buttons still don't work.

@syntactical, vendor-all.min.js is the min.js file of my template.

Activity icon

Replied to The Integration Of Vuejs In A Bootstrap Template Failed

I have already done everything you are asking to do. The problem lies with template. If I use the app.js provided by default from Laravel, everything works fine and the windows and buttons respond correctly, on the other hand if I use a bootstrap template, I receive this error and nothing works correctly, window shifted, buttons which do not respond and everything in between. It seems that the template's min.js file conflicts with the app.js file. In my example it is <script src =" assets / js / vendor-all.min.js "> </script> which will conflict with <script src =" {{mix ('js / app. js')}} "> </script> and I don't know why.

Mar
23
3 weeks ago
Activity icon

Replied to The Integration Of Vuejs In A Bootstrap Template Failed

webpack.mix.js

const mix = require('laravel-mix');

mix.js('resources/js/app.js', 'public/js')
    .sass('resources/sass/app.scss', 'public/css');
// mix.js('resources/js/app.min.js', 'public/js')
mix.minify('public/assets/js/vendor-all.min.js')
    .minify('public/assets/js/plugins/bootstrap.min.js');

app.js

window.$ = window.jQuery = require('jquery');
window.Popper = require('popper.js');
require('./bootstrap');

require('@fortawesome/fontawesome-free/js/all.js');

window.Vue = require('vue');


import 'bootstrap/dist/css/bootstrap.css';
import 'bootstrap-vue/dist/bootstrap-vue.css';

Vue.component('example-component', require('./components/ExampleComponent.vue').default);

const app = new Vue({
    el: '#app',
});
Activity icon

Replied to The Integration Of Vuejs In A Bootstrap Template Failed

@syntactical, i have done like you suggest but nothing different I tried the solution you suggested, but unfortunately nothing changed I have 09 errors now instead of 4. Among others Uncaught TypeError: can't access property" extend ", s is undefined

Activity icon

Replied to The Integration Of Vuejs In A Bootstrap Template Failed

@syntactical , here are the errors im getting in the console

Uncaught ReferenceError: jQuery is not defined,

Uncaught TypeError: a is not a function,

Uncaught ReferenceError: $ is not defined,

Uncaught ReferenceError: PerfectScrollbar is not defined

Mar
21
3 weeks ago
Activity icon

Started a new Conversation The Integration Of Vuejs In A Bootstrap Template Failed

Hi, I am using a Bootstrap Template and am having an issue. indeed, when I import <script src =" {{mix ('js / app.js')}} "> </script> in the file app.blade.php, all the buttons and the css of my template get disabled, as well as the javascript file vendor-all.min.js of my application. But, when i comment <script src =" {{mix ('js / app.js')}} "> </script> everything comes to normal and works very well. This is the third bootstrap's template I am using and it gives me the same error.

This my app.blade.php

<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">

<head>
  
    <meta name="csrf-token" content="{{ csrf_token() }}">
    <title>R&D LoungeApp</title>
    <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
    <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimal-ui">
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />

    <!-- Favicon icon -->
    <link rel="icon" href="{{ asset('assets/images/logo_r&d.png') }}" type="image/x-icon">

    @yield('css')
    <!-- vendor css -->
    <link rel="stylesheet" href="{{ asset('assets/css/style.css') }}">


</head>

<body class="">
    <div class="loader"></div>
    <div id="app">
        <!-- [ Pre-loader ] start -->

        <div class="loader-bg">
            <div class="loader-track">
                <div class="loader-fill"></div>
            </div>
        </div>
        <!-- [ Pre-loader ] End -->

        <!-- [ navigation menu ] start -->
        <!-- Navbar Content (barre de navigation horizontale)-->
        @include('base.navbar')
        <!-- [ navigation menu ] end -->

        <!-- [ Header ] start -->
        <!-- Header Content (barre de menu vertical)-->
        @include('base.header')
        <!-- [ Header ] end -->

        <!-- [ Main Content ] start -->
        <div class="pcoded-main-container">

            @yield('content')
            @yield('vuejs')

        </div>
        <!-- [ Main Content ] end -->
   

        <!-- Required Js -->
        <script src="assets/js/vendor-all.min.js"></script>
        <script src="assets/js/plugins/bootstrap.min.js"></script>
        <script src="assets/js/pcoded.min.js"></script>
        <script src="assets/js/menu-setting.min.js"></script>


        @yield('javascript')
      
    </div>
    <!-- Footer -->
    @include('base.footer')

    <!-- Scripts VueJS-->
    <script src="{{ mix('js/app.js') }}"></script> 
</body>

</html>

I need your help. Thank you in advance.

Mar
09
1 month ago
Activity icon

Started a new Conversation How To Get Div Disable And Background Grey After A Condition

Hi, I would like to desable a div card-container and put the gray background if the number of product.current_stock is = 0`.

Here is my div

<div class="card-container">
        <div
          v-for="productin filteredList"
          class="card"
          v-bind:key="produit.id"
          id="panier"
        >
          <div class="img-container" id="disable" disabled>
            <img :src="'/uploads/products/' + product.image" />
          </div>

          <div class="card-text" id="disable" disabled>
            <h3>{{ product.nom }}</h3>
            <h5>{{ product.current_stock }}</h5>
            <span>{{ product.prix }} FCFA</span>
          </div>

          <div class="card-icons" id="disable" disabled>
            <div class="add-to-cart" id="disable" disabled>
              <button v-on:click="addToCart(produit)">
                <i class="fas fa-plus-square"></i>
              </button>
            </div>
          </div>
        </div>

        <!-- no result message -->
        <div v-if="filteredList.length == []" class="no-result">
          <h3>Désolé</h3>
          <p>Aucun résultat trouvé</p>
        </div>
      </div>

I am totally lost, I need your help.

Thank you in advance

Mar
03
1 month ago
Activity icon

Replied to Personalized Display Of The Fields Of A Foreign Key In A Bootstrap-vue Table

Sorry i forgot the script, here is it

data() {
    return {
      filter: "",
      fields: [
        {
          key: "voir",
          label: "",
        },
        {
          key: "produit_id",
          label: "Produit",
          sortable: true,
        },

        {
          key: "stock_actuel",
          label: "Qté en stock",
          sortable: true,
          sortDirection: "desc",
        },
        {
          key: "stock_minimal",
          label: "Qté Minimale",
          sortable: true,
        },
        {
          key: "edit",
          label: "",
        },
        {
          key: "delete",
          label: "",
        },
      ],
      items: [],
      produits: [],
      nom: "",
      stock_actuel: "",
      stock_minimal: "",
  },
 mounted() {
    console.log("Component mounted.");
    this.listStocks();
    this.listProduits();
  },
methods: {
    listProduits() {
      axios.get("/api/listproduits").then(
        function (response) {
          this.produits = response.data.data;
        }.bind(this)
      );
    },
Mar
02
1 month ago
Activity icon

Awarded Best Reply on Laravel 8 Storage::delete (file) Return False

After several research I was able to find the right way, instead of Storage :: delete (public_path ('/ uploads / avatars /'. Auth :: user () -> avatar)); I used instead File :: delete (public_path ('/ uploads / avatars /'. Auth :: user () -> avatar)); and that deletes and saves the file properly. Thank you for the help.

Activity icon

Awarded Best Reply on Delete Edit Row And Display Image In Boostrap-vue Datable

I found the solution, so this is it : The table code

<template #cell(image)="data">
                        <div>
                          <center>
                            <button
                              v-on:click="getProduit(data.item.id)"
                              data-target="#modalShow"
                            >
                              <img
                                class="c-avatar-prod"
                                center
                                :src="'/uploads/produits/' + data.item.image"
                                alt="Produit image"
                              />
                            </button>
                          </center>
                        </div>
                      </template>
                      <template #cell(edit)="data">
                        <center>
                          <button
                            class="btn btn-sm btn-outline-info"
                            v-on:click="editProduit(data.item.id)"
                            data-target="#modalEdit"
                          >
                            <i class="fas fa-pen"></i>
                          </button>
                        </center>
                      </template>
                      <template #cell(delete)="data">
                        <center>
                          <button
                            class="btn btn-sm btn-outline-danger"
                            v-on:click="getID(data.item.id)"
                          >
                            <i class="fas fa-trash"></i>
                          </button>
                        </center>
                      </template>

The script code for get product

getProduit(id) {
      // alert (id);
      axios
        .get("/api/show/" + id)
        .then((response) => {
          this.id = response.data.id;
          this.nom = response.data.nom;
          this.description = response.data.description;
          this.prix = response.data.prix;
          this.type = response.data.type;
          this.image = response.data.image;
          this.fournisseurs_id = response.data.fournisseurs_id;
          this.users_id = response.data.users_id;
          this.$refs.myModalRefShow.show();
        })
        .catch((error) => console.log(error));
    },

The script code for edit product

editProduit(id) {
      axios
        .get("/api/edit/" + id)
        .then((response) => {
          this.id = response.data.id;
          this.nom = response.data.nom;
          this.description = response.data.description;
          this.prix = response.data.prix;
          this.type = response.data.type;
          this.image = response.data.image;
          this.categories_id = response.data.categories_id;
          this.fournisseurs_id = response.data.fournisseurs_id;
          this.users_id = response.data.users_id;
          this.$refs.myModalRefEdit.show();
        })
        .catch((error) => console.log(error));
    },

The script code for update product

updateProduit() {
      const data = new FormData();

      data.append("nom", this.nom);
      data.append("description", this.description);
      data.append("prix", this.prix);
      data.append("type", this.type);
      data.append("image", this.image);
      data.append("categories_id", this.categories_id);
      data.append("fournisseurs_id", this.fournisseurs_id);
      data.append("users_id", this.users_id);
      const config = {
        headers: {
          "content-type": "multipart/form-data",
          "X-CSRF-TOKEN": document.querySelector('meta[name="csrf-token"]')
            .content,
        },
      };
      axios
        .post("/api/updateProduit/" + this.id, data, config)
        .then((response) => {
          this.form.reset();
          window.location = response.data.redirect;
        })
        .then(location.reload())
        .catch(function (error) {
          console.log(error);
        });
    },

The script code for delete product

deleteItem(id) {
      axios
        .delete("/api/delete/" + id)
        .then((response) => {
          const index = this.items.findIndex((produit) => produit.id === id); // find the product index
          if (~index)
            // if the product exists in array
            this.items.splice(index, 1); //delete the product
          window.location = response.redirect;
        })
        // .then(location.reload())
        .catch(function (error) {
          console.log(error);
        });
      this.$refs.myModalRefDelete.hide();
    },

The Controller

// edit product for select product
    public function edit($id)
    {
        $produit = Produits::find($id);
        return response()->json($produit);
    }

    // update product
    public  function updateProduit(Request $request, $id)
    {
        $produit = Produits::find($id);

        // $produit->id = $request->input('id');
        info($request->all());
        $produit->nom = $request->nom;
        $produit->description = $request->input('description');
        $produit->prix = $request->input('prix');
        $produit->type = $request->input('type');
        $produit->categories_id = $request->input('categories_id');
        $produit->fournisseurs_id = $request->get('fournisseurs_id');
        $produit->users_id = $request->input('users_id');
        $produit->image = $request->input('image');
        if ($request->hasfile('image')) {
            $image = $request->file('image');
            $originalName = $image->getClientOriginalName();
            // $fileExtension = $image->getClientOriginalExtension();
            $filename = $originalName;
            if ($produit->image && $produit->image == 'noproductimage.jpg') {
                Image::make($image)->resize(500, 500)->save(public_path('/uploads/produits/' . $filename));
            } else {
                File::delete(public_path('/uploads/produits/' . $produit->image));
                Image::make($image)->resize(500, 500)->save(public_path('/uploads/produits/' . $filename));
            }
            $produit->image = $filename;
        };
        $produit->save();
        dd($produit);
        return response()->json(['success' => 'Produit modifié avec succès']);
    }

    public function update($id, Request $request)
    {
        $produit = Produits::find($id);
        $produit->update($request->all());

        return response()->json('Le produit a été modifié avec succès');
    }

    // delete product
    public function delete($id)
    {
        $produit = Produits::find($id);
        $produit->delete();

        return response()->json('Le produit a été supprimé avec succès');
    }

    // show product
    public function show($id)
    {
        $produit = Produits::find($id);
        return response()->json($produit);
    }
Activity icon

Replied to Delete Edit Row And Display Image In Boostrap-vue Datable

I found the solution, so this is it : The table code

<template #cell(image)="data">
                        <div>
                          <center>
                            <button
                              v-on:click="getProduit(data.item.id)"
                              data-target="#modalShow"
                            >
                              <img
                                class="c-avatar-prod"
                                center
                                :src="'/uploads/produits/' + data.item.image"
                                alt="Produit image"
                              />
                            </button>
                          </center>
                        </div>
                      </template>
                      <template #cell(edit)="data">
                        <center>
                          <button
                            class="btn btn-sm btn-outline-info"
                            v-on:click="editProduit(data.item.id)"
                            data-target="#modalEdit"
                          >
                            <i class="fas fa-pen"></i>
                          </button>
                        </center>
                      </template>
                      <template #cell(delete)="data">
                        <center>
                          <button
                            class="btn btn-sm btn-outline-danger"
                            v-on:click="getID(data.item.id)"
                          >
                            <i class="fas fa-trash"></i>
                          </button>
                        </center>
                      </template>

The script code for get product

getProduit(id) {
      // alert (id);
      axios
        .get("/api/show/" + id)
        .then((response) => {
          this.id = response.data.id;
          this.nom = response.data.nom;
          this.description = response.data.description;
          this.prix = response.data.prix;
          this.type = response.data.type;
          this.image = response.data.image;
          this.fournisseurs_id = response.data.fournisseurs_id;
          this.users_id = response.data.users_id;
          this.$refs.myModalRefShow.show();
        })
        .catch((error) => console.log(error));
    },

The script code for edit product

editProduit(id) {
      axios
        .get("/api/edit/" + id)
        .then((response) => {
          this.id = response.data.id;
          this.nom = response.data.nom;
          this.description = response.data.description;
          this.prix = response.data.prix;
          this.type = response.data.type;
          this.image = response.data.image;
          this.categories_id = response.data.categories_id;
          this.fournisseurs_id = response.data.fournisseurs_id;
          this.users_id = response.data.users_id;
          this.$refs.myModalRefEdit.show();
        })
        .catch((error) => console.log(error));
    },

The script code for update product

updateProduit() {
      const data = new FormData();

      data.append("nom", this.nom);
      data.append("description", this.description);
      data.append("prix", this.prix);
      data.append("type", this.type);
      data.append("image", this.image);
      data.append("categories_id", this.categories_id);
      data.append("fournisseurs_id", this.fournisseurs_id);
      data.append("users_id", this.users_id);
      const config = {
        headers: {
          "content-type": "multipart/form-data",
          "X-CSRF-TOKEN": document.querySelector('meta[name="csrf-token"]')
            .content,
        },
      };
      axios
        .post("/api/updateProduit/" + this.id, data, config)
        .then((response) => {
          this.form.reset();
          window.location = response.data.redirect;
        })
        .then(location.reload())
        .catch(function (error) {
          console.log(error);
        });
    },

The script code for delete product

deleteItem(id) {
      axios
        .delete("/api/delete/" + id)
        .then((response) => {
          const index = this.items.findIndex((produit) => produit.id === id); // find the product index
          if (~index)
            // if the product exists in array
            this.items.splice(index, 1); //delete the product
          window.location = response.redirect;
        })
        // .then(location.reload())
        .catch(function (error) {
          console.log(error);
        });
      this.$refs.myModalRefDelete.hide();
    },

The Controller

// edit product for select product
    public function edit($id)
    {
        $produit = Produits::find($id);
        return response()->json($produit);
    }

    // update product
    public  function updateProduit(Request $request, $id)
    {
        $produit = Produits::find($id);

        // $produit->id = $request->input('id');
        info($request->all());
        $produit->nom = $request->nom;
        $produit->description = $request->input('description');
        $produit->prix = $request->input('prix');
        $produit->type = $request->input('type');
        $produit->categories_id = $request->input('categories_id');
        $produit->fournisseurs_id = $request->get('fournisseurs_id');
        $produit->users_id = $request->input('users_id');
        $produit->image = $request->input('image');
        if ($request->hasfile('image')) {
            $image = $request->file('image');
            $originalName = $image->getClientOriginalName();
            // $fileExtension = $image->getClientOriginalExtension();
            $filename = $originalName;
            if ($produit->image && $produit->image == 'noproductimage.jpg') {
                Image::make($image)->resize(500, 500)->save(public_path('/uploads/produits/' . $filename));
            } else {
                File::delete(public_path('/uploads/produits/' . $produit->image));
                Image::make($image)->resize(500, 500)->save(public_path('/uploads/produits/' . $filename));
            }
            $produit->image = $filename;
        };
        $produit->save();
        dd($produit);
        return response()->json(['success' => 'Produit modifié avec succès']);
    }

    public function update($id, Request $request)
    {
        $produit = Produits::find($id);
        $produit->update($request->all());

        return response()->json('Le produit a été modifié avec succès');
    }

    // delete product
    public function delete($id)
    {
        $produit = Produits::find($id);
        $produit->delete();

        return response()->json('Le produit a été supprimé avec succès');
    }

    // show product
    public function show($id)
    {
        $produit = Produits::find($id);
        return response()->json($produit);
    }
Activity icon

Awarded Best Reply on Can't Display Image On Bootstrap-vue Datable

I found the solution and this how i manage it : the table code

<template #cell(image)="data">
   <div>
     <center>
       <button
       v-on:click="getProduit(data.item.id)"
       data-target="#modalShow">
       <img class="c-avatar-prod" center
       :src="'/uploads/produits/' + data.item.image"
        alt="Produit image" />
       </button>
     </center>
   </div>
</template>
Activity icon

Replied to Can't Display Image On Bootstrap-vue Datable

I found the solution and this how i manage it : the table code

<template #cell(image)="data">
   <div>
     <center>
       <button
       v-on:click="getProduit(data.item.id)"
       data-target="#modalShow">
       <img class="c-avatar-prod" center
       :src="'/uploads/produits/' + data.item.image"
        alt="Produit image" />
       </button>
     </center>
   </div>
</template>
Mar
01
1 month ago
Activity icon

Replied to Personalized Display Of The Fields Of A Foreign Key In A Bootstrap-vue Table

Is it possible to create a specific question for your post please.

Activity icon

Awarded Best Reply on Update In Laravel VueJs

I got the solution of my problem Here is the solution :

<template #cell(edit)="data">
   <center>
       <button class="btn btn-sm btn-outline-info"
        v-on:click="editProduit(data.item.id)"
        data-target="#modalEdit">
        <i class="fas fa-pen"></i>
       </button>
  </center>
 </template>

the script, Get the product on the Modal

editProduit(id) {
      axios
        .get("/api/edit/" + id)
        .then((response) => {
          this.id = response.data.id;
          this.nom = response.data.nom;
          this.description = response.data.description;
          this.prix = response.data.prix;
          this.type = response.data.type;
          this.image = response.data.image;
          this.categories_id = response.data.categories_id;
          this.fournisseurs_id = response.data.fournisseurs_id;
          this.users_id = response.data.users_id;
          this.$refs.myModalRefEdit.show();
        })
        .catch((error) => console.log(error));
    },

The update method product on the Modal

    updateProduit() {
      const data = new FormData();

      data.append("nom", this.nom);
      data.append("description", this.description);
      data.append("prix", this.prix);
      data.append("type", this.type);
      data.append("image", this.image);
      data.append("categories_id", this.categories_id);
      data.append("fournisseurs_id", this.fournisseurs_id);
      data.append("users_id", this.users_id);
      const config = {
        headers: {
          "content-type": "multipart/form-data",
          "X-CSRF-TOKEN": document.querySelector('meta[name="csrf-token"]')
            .content,
        },
      };
      axios
        .post("/api/updateProduit/" + this.id, data, config)
        .then((response) => {
          this.form.reset();
          window.location = response.data.redirect;
        })
        .then(location.reload())
        .catch(function (error) {
          console.log(error);
        });
    },
Activity icon

Replied to Update In Laravel VueJs

I got the solution of my problem Here is the solution :

<template #cell(edit)="data">
   <center>
       <button class="btn btn-sm btn-outline-info"
        v-on:click="editProduit(data.item.id)"
        data-target="#modalEdit">
        <i class="fas fa-pen"></i>
       </button>
  </center>
 </template>

the script, Get the product on the Modal

editProduit(id) {
      axios
        .get("/api/edit/" + id)
        .then((response) => {
          this.id = response.data.id;
          this.nom = response.data.nom;
          this.description = response.data.description;
          this.prix = response.data.prix;
          this.type = response.data.type;
          this.image = response.data.image;
          this.categories_id = response.data.categories_id;
          this.fournisseurs_id = response.data.fournisseurs_id;
          this.users_id = response.data.users_id;
          this.$refs.myModalRefEdit.show();
        })
        .catch((error) => console.log(error));
    },

The update method product on the Modal

    updateProduit() {
      const data = new FormData();

      data.append("nom", this.nom);
      data.append("description", this.description);
      data.append("prix", this.prix);
      data.append("type", this.type);
      data.append("image", this.image);
      data.append("categories_id", this.categories_id);
      data.append("fournisseurs_id", this.fournisseurs_id);
      data.append("users_id", this.users_id);
      const config = {
        headers: {
          "content-type": "multipart/form-data",
          "X-CSRF-TOKEN": document.querySelector('meta[name="csrf-token"]')
            .content,
        },
      };
      axios
        .post("/api/updateProduit/" + this.id, data, config)
        .then((response) => {
          this.form.reset();
          window.location = response.data.redirect;
        })
        .then(location.reload())
        .catch(function (error) {
          console.log(error);
        });
    },
Activity icon

Started a new Conversation Personalized Display Of The Fields Of A Foreign Key In A Bootstrap-vue Table

Hi everyone, I have a bootstrap-vue Table, and I have a Stock entity in which I have a product_id foreign key. When the table pops up, it returns the product id's, but I want that the table fetch the product name. Indeed, I am looking for a tutorial that can help with this. My datatable code

<b-table
              :striped="striped"
              :bordered="bordered"
              :borderless="borderless"
              :outlined="outlined"
              :sort-by.sync="sortBy"
              :sort-desc.sync="sortDesc"
              :current-page="currentPage"
              :per-page="perPage"
              :filter="filter"
              :small="small"
              :hover="hover"
              :dark="dark"
              :fixed="fixed"
              :foot-clone="footClone"
              :no-border-collapse="noCollapse"
              :items="items"
              :fields="fields"
              :head-variant="headVariant"
              :table-variant="tableVariant"
            >
              <template #cell(voir)="data">
                <center>
                  <button
                    class="btn btn-sm btn-outline-success"
                    v-on:click="getStock(data.item.id)"
                    data-target="#modalEdit"
                  >
                    <i class="fas fa-eye"></i>
                  </button>
                </center>
              </template>

              <template #cell(produits_id)="data">
                <center>
                  {{ data.item.produits_id }}
                </center>
              </template>

              <!-- <template slot="produits_id" slot-scope="data"><center>{{ data.item.produits_id }}</center></template> -->

              <template #cell(edit)="data">
                <center>
                  <button
                    class="btn btn-sm btn-outline-info"
                    v-on:click="editStock(data.item.id)"
                    data-target="#modalEdit"
                  >
                    <i class="fas fa-pen"></i>
                  </button>
                </center>
              </template>

              <template #cell(delete)="data">
                <center>
                  <button
                    class="btn btn-sm btn-outline-danger"
                    v-on:click="getID(data.item.id)"
                  >
                    <i class="fas fa-trash"></i>
                  </button>
                </center>
              </template>
            </b-table>

Thanks in advance for help.

Feb
17
1 month ago
Activity icon

Replied to Update In Laravel VueJs

@piljac1 , this is the error i get on the storage/logs

local.ERROR: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'id' cannot be null (SQL: update `produits` set `id` = ?, `nom` = ?, `description` = ?, `prix` = ?, `type` = ?, `image` = ?, `users_id` = ?, `categories_id` = ?, `produits`.`updated_at` = 2021-02-18 01:05:16 where `id` = 3)

local.ERROR: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'nom' cannot be null (SQL: update `produits` set `nom` = ?, `description` = ?, `prix` = ?, `type` = ?, `image` = ?, `users_id` = ?, `categories_id` = ?, `produits`.`updated_at` = 2021-02-18 01:06:55 where `id` = 3)

I can't understand i get this error..

Activity icon

Replied to Update In Laravel VueJs

@apex1, I changed $produit->update(); with $produit->save(); and nothing i get the same error. By the way i have also used

public function update($id, Request $request)
    {
        $produit = Produits::find($id);
        $produit->update($request->all());

        return response()->json('Le produit a été modifié avec succès');
    }

and i get the same error : ` PUT http://localhost:2410/api/updateProduit/5 [HTTP/1.1 500 Internal Server Error 371ms] Error: Request failed with status code 500

Feb
16
1 month ago
Activity icon

Replied to Update In Laravel VueJs

It is Produits

Activity icon

Replied to Update In Laravel VueJs

@martinbean , @apex1 , @msslgomez , @i have updated my code please help me. Thanks in advance.

Feb
09
2 months ago
Activity icon

Started a new Conversation Update In Laravel VueJs

Hi, I would like to set up a CRUD, in Laravel and so far the Create, Read and Delete have worked fine. I get the error Error: Request failed with status code 500 when i want to update the product element.

Here is my code: 1- my update code in vue

updateProduit() {
        // alert (this.id);
        const config = {
        headers: {
          "content-type": "multipart/form-data",
          "X-CSRF-TOKEN": document.querySelector('meta[name="csrf-token"]')
            .content,
        },
      };
        axios.put("/api/updateProduit/" + this.id, config, {
            id : this.id,
            nom : this.nom,
            description : this.description,
            prix : this.prix,
            type : this.type,
            image : this.image,
            categories_id : this.categories_id
        })
        // .then(response => {
        //   this.form.reset();
        //   window.location = response.data.redirect;
        // })
        // .then(location.reload())
        .catch(function (error) {
          console.log(error);
        })
    },

the controller

// update product
    public  function updateProduit(Request $request, $id)
    {
        $produit = Produits::find($id);

        $produit->id = $request->id;
        $produit->nom = $request->nom;
        $produit->description = $request->description;
        $produit->prix = $request->prix;
        $produit->type = $request->type;
        $produit->categories_id = $request->categories_id;
        $produit->users_id = $request->users_id;
        $produit->image = $request->image;
        if ($request->hasfile('image')) {
            $image = $request->file('image');
            $originalName = $image->getClientOriginalName();
            // $fileExtension = $image->getClientOriginalExtension();
            $filename = $originalName;
            if ($produit->image && $produit->image == 'noproductimage.jpg') {
                Image::make($image)->resize(500, 500)->save(public_path('/uploads/produits/' . $filename));
            } else {
                File::delete(public_path('/uploads/produits/' . $produit->image));
                Image::make($image)->resize(500, 500)->save(public_path('/uploads/produits/' . $filename));
            }
            $produit->image = $filename;
        };
        $produit->update();
        return response()->json(['success' => 'Produit modifié avec succès']);
    }

The route

Route::put('/updateProduit/{id}', [App\Http\Controllers\Api\ProduitController::class, 'updateProduit'])->name('updateProduit');

what did i do wrong, Please i need your help, For 3 weeks, I have stagnated in the same place.

Thanks in advance

Jan
08
3 months ago
Activity icon

Started a new Conversation Delete Edit Row And Display Image In Boostrap-vue Datable

Hi, im looking how to delete and Edita row in Boostrap-vue Datable this is my Controller

// edit post
    public function edit($id)
    {
        $produit = Produits::find($id);
        return response()->json($produit);
    }


    // update post
    public function update($id, Request $request)
    {
        $produit = Produits::find($id);
        $produit->update($request->all());

        return response()->json('Le produit a été modifié avec succès');
    }

    // delete post
    public function delete($id)
    {
        $produit = Produits::find($id);
        $produit->delete();

        return response()->json('Le produit a été supprimé avec succès');
    }

and this my vue


<template>
<b-table
                      :striped="striped"
                      :bordered="bordered"
                      :borderless="borderless"
                      :outlined="outlined"
                      :sort-by.sync="sortBy"
                      :sort-desc.sync="sortDesc"
                      :current-page="currentPage"
                      :per-page="perPage"
                      :filter="filter"
                      :small="small"
                      :hover="hover"
                      :dark="dark"
                      :fixed="fixed"
                      :foot-clone="footClone"
                      :no-border-collapse="noCollapse"
                      :items="items"
                      :fields="fields"
                      :head-variant="headVariant"
                      :table-variant="tableVariant"
                    >
                      <template #cell(image)="row">
                        <div>
                          <img
                            v-on:click="
                              info(row.item, row.index, $event.target)
                            "
                            v-bind="mainProps"
                            center
                            :src="'/uploads/produits/' + fields.image"
                            alt="Produit image"
                          />
                          <!-- <div>
                              <vue-load-image>
                                  <img slot="image" src="./image.png"/>
                                  <img slot="preloader" src="./image-loader.gif"/>
                                  <div slot="error">error message</div>
                              </vue-load-image>
                          </div> -->
                        </div>
                      </template>
                      <template #cell(edit)="row">
                        <a
                          class="btn btn-sm btn-outline-info"
                          v-on:click="info(row.item, row.index, $event.target)"
                        >
                          <i class="fas fa-pen"></i>
                        </a>
                      </template>
                      <template #cell(delete)="row">
                        <button
                          class="btn btn-sm btn-outline-danger"
                          v-on:click="deleteProduct(row.item.id)"
                        >
                          <i class="fas fa-trash"></i>
                        </button>
                      </template>
                    </b-table>>
              <div class="row">
                <div class="col-xs-12 form-inline">
                  <datatable-pager
                    v-model="page"
                    type="abbreviated"
                    :per-page="per_page"
                  ></datatable-pager>
                </div>
              </div>
</template>

<script>
import Vue from "vue";
import { BootstrapVue, IconsPlugin } from "bootstrap-vue";

// Install BootstrapVue
Vue.use(BootstrapVue);
// Optionally install the BootstrapVue icon components plugin
Vue.use(IconsPlugin);

import VueLoadImage from "vue-load-image";

export default {
  components: {
    "vue-load-image": VueLoadImage,
  },
  data() {
    return {
      filter: "",
      fields: [
        { key: "image", label: "" },
        { key: "nom", label: "Nom", sortable: true },
        {
          key: "description",
          label: "Description",
          sortable: true,
          sortDirection: "desc",
        },
        { key: "prix", label: "Prix", sortable: true },
        { key: "edit", label: "" },
        { key: "delete", label: "" },
      ],
      items: [],
      mainProps: {
        width: 55,
        height: 55,
        class: "my-5",
      },
      tableVariants: [
        "primary",
        "secondary",
        "info",
        "danger",
        "warning",
        "success",
        "light",
        "dark",
      ],
      striped: false,
      bordered: false,
      borderless: false,
      outlined: false,
      small: false,
      hover: false,
      dark: false,
      fixed: false,
      footClone: false,
      headVariant: null,
      tableVariant: "",
      noCollapse: false,
      totalRows: 1,
      currentPage: 1,
      perPage: 5,
      pageOptions: [5, 10, 15, 25, 100, { value: 1000, text: "Toutes" }],
      sortBy: "",
      sortDesc: false,
      sortDirection: "asc",
      filterOn: [],
    };
  },
  computed: {
    sortOptions() {
      // Create an options list from our fields
      return this.fields
        .filter((f) => f.sortable)
        .map((f) => {
          return { text: f.label, value: f.key };
        });
    },
  },
  mounted() {
    axios.get("/api/listproduits").then(
      function (response) {
        this.items = response.data.data;
        this.totalRows = this.items.length;
      }.bind(this)
    );
  },
  methods: {
    onFiltered(filteredItems) {
      // Trigger pagination to update the number of buttons/pages due to filtering
      this.totalRows = filteredItems.length;
      this.currentPage = 1;
    },
    getProduictImage() {
      return "";
    },
    deleteProduct(id) {
        this.axios
        .delete(`api/delete/${id}`)
        .then(response => {
            let i = this.items.map(item => item.id).indexOf(id); // find index of your object
            this.items.splice(i, 1)
            });
        },
  },
  created: function () {
    this.getProduits();
  },
};
</script>

Somehow, it's not work. Thank you in advance for your help.

Dec
30
3 months ago
Activity icon

Replied to Laravel 8 Vuejs Image Doesn't Upload And Save To Database

@marianomoreyra I found the problem preventing the item from being saved to the database. I found the problem preventing the item from being saved to the database. So, I added in config-> App.php this lines 'providers' => Intervention\Image\ImageServiceProvider::class, 'Image' => Intervention\Image\Facades\Image::class, and now it save and image to folder and items to database. Thank you for your precious help..

Dec
28
3 months ago
Activity icon

Replied to Laravel 8 Vuejs Image Doesn't Upload And Save To Database

@marianomoreyra unfortunately the network console does not return any error. It recharges without sending an error

Dec
26
3 months ago
Activity icon

Replied to Laravel 8 Vuejs Image Doesn't Upload And Save To Database

@marianomoreyra Nothing have changed, it save the image in the storage, but nothing in the database. How can we explain that

store() {
      axios
        .post("/api/createproduit", {
          // /api/createproduit = au chemin depuis route -> api.php
          nom: this.nom,
          description: this.description,
          prix: this.prix,
          type: this.type,
          image: this.image,
          categories_id: this.categories_id,
          users_id: document
            .querySelector("meta[name='users_id']")
            .getAttribute("content"),
          headers: {
            "content-type": "multipart/form-data",
            "X-CSRF-TOKEN": document.querySelector('meta[name="csrf-token"]')
              .content,
          },
        })
        .then((response) => {
          this.produits = response.data.data;
          this.loading = false;
          this.form.reset();
          window.location = response.data.redirect;
        })
        .then(location.reload())
        .catch(function (error) {
          console.log(error);
        });
    },
  },

saves in the database without save the image and

store() {
        const data = new FormData()

      data.append('nom', this.nom)
      data.append('description', this.description)
      data.append('prix', this.prix)
      data.append('type', this.type)
      data.append('image', this.image)
      data.append('categories_id', this.categories_id)
      data.append('users_id', document
            .querySelector("meta[name='users_id']")
            .getAttribute("content"))
      axios
        .post("/api/createproduit",data)
        .then((response) => {
          this.produits = response.data.data;
          this.loading = false;
          this.form.reset();
          window.location = response.data.redirect;
        })
        .then(location.reload())
        .catch(function (error) {
          console.log(error);
        });
    }

did not save anything. Hum it's really frustrating.

Activity icon

Replied to Laravel 8 Vuejs Image Doesn't Upload And Save To Database

@marianomoreyra , sorry to tell you that it does not work.

Dec
24
3 months ago
Activity icon

Replied to Can't Display Image On Bootstrap-vue Datable

@marianomoreyra , the system loads the page but slowly and many times. Indeed,after putting the v-for="produit in items" , the system becomes slow and continuously reloads the same page.

Activity icon

Replied to Laravel 8 Vuejs Image Doesn't Upload And Save To Database

@marianomoreyra , I tried your code, but unfortunately it doesn't work 100%. Unlike my code, It does save the image in folder, but does not save the product in the database. Having tried to recover your code mix with mine nothing, this time no data, neither the image, nor the data is recorded.

Dec
23
3 months ago
Activity icon

Replied to Laravel 8 Vuejs Image Doesn't Upload And Save To Database

@mvd , @hdsavani , I was able to fetch the image and save it to the product table, but in a way that I ignore the image is not fetched and save in the path. nb: this code works with blade without vuejs, but as soon as i integrate it with vuejs, it doesn't save the image. Please help me.

my code : my controller

public function store(Request $request)
    {
        $request['data'] = json_decode($request['data']);
        $produit = new Produits;
        if ($request->hasfile('image')) {
            $image = $request->file('image');
            $filename = $produit->nom . '_' . time() . '.' . $image->getClientOriginalExtension();
            if ($produit->image && $produit->image == 'noproductimage.jpg') {
                Image::make($image)->resize(500, 500)->save(public_path('/uploads/produits/' . $filename));
            } else {
                File::delete(public_path('/uploads/produits/' . $produit->image));
                Image::make($image)->resize(500, 500)->save(public_path('/uploads/produits/' . $filename));
            }
            $produit->image = $filename;
        }
        $produit->nom = $request->get('nom');
        $produit->description = $request->get('description');
        $produit->prix = $request->get('prix');
        $produit->type = $request->get('type');
        $produit->categories_id = $request->get('categories_id');
        $produit->users_id = $request->get('users_id');
        $produit->image = $request->get('image');
        $request->file('image')->store('pictures');
        $produit->save();
        return response()->json(['success' => 'Produit enregistré avec succès']);
    }

my vuejs page

<template>
  <div class="container-fluid">
    <div class="animated fadeIn">
      <div class="row">
        <div class="col-sm-12 col-md-10 col-lg-8 col-xl-6">
          <div class="card">
            <div class="card-header">
              <i class="fa fa-align-justify"></i>
              {{ "Créer un Produit" }}
              <span class="badge float-right">
                <a
                  v-bind:href="'/listproduits'"
                  class="btn btn-sm btn-outline-info"
                  title="Liste des produits"
                >
                  <i class="fas fa-list"></i>
                </a>
              </span>
            </div>

            <div class="card-body">
              <form @submit.prevent="store" enctype="multipart/form-data">
                <div class="form-group row">
                  <label></label>
                  <input
                    class="form-control"
                    type="text"
                    placeholder="Nom du produit"
                    v-model="nom"
                    required
                    autofocus
                  />
                </div>

                <div class="form-group row">
                  <label></label>
                  <textarea
                    class="form-control"
                    id="textarea-input"
                    v-model="description"
                    rows="6"
                    placeholder="Description du Produit"
                    required
                  ></textarea>
                </div>

                <div class="input-group row">
                  <label></label>
                  <input
                    type="text"
                    class="form-control"
                    v-model="prix"
                    placeholder="Prix du produit"
                  />
                  <div class="input-group-append">
                    <span class="input-group-text">FCFA</span>
                  </div>
                </div>

                <div class="form-group row">
                  <label>Categories:</label>
                  <select
                    class="form-control"
                    v-model="categories_id"
                    @change="getCategories()"
                  >
                    <option disabled value="">
                      Sélectionner une catégorie
                    </option>
                    <option
                      v-for="categorie in categories"
                      v-bind:key="categorie.id"
                      v-bind:value="categorie.id"
                    >
                      {{ categorie.nom }}
                    </option>
                  </select>
                </div>

                <div class="form-group row">
                  <div class="col-md-9">
                    <input
                      id="file-input"
                      placeholder="Image du produit"
                      type="file"
                      name="image"
                      @change="onFileChange"
                      v-on:change="image"
                    />
                  </div>
                </div>

                <div class="form-group row">
                  <label></label>
                  <input
                    class="form-control"
                    type="text"
                    placeholder="Type du produit"
                    v-model="type"
                    required
                    autofocus
                  />
                </div>

                <div class="form-group row">
                  <label></label>
                  <input
                    class="form-control"
                    type="hidden"
                    placeholder=""
                    v-model="users_id"
                    required
                    autofocus
                  />
                </div>

                <button
                  class="btn btn-block pull-right btn btn-sm btn-outline-info"
                  type="submit"
                >
                  {{ "Valider" }}
                </button>
                <a href="" class="btn btn-block btn btn-sm btn-info">
                  {{ "Retourner" }}
                </a>
              </form>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      categories_id: "",
      categories: [],
      nom: "",
      description: "",
      prix: "",
      type: "",
      image: "",
      users_id: document
        .querySelector("meta[name='users_id']")
        .getAttribute("content"),
    };
  },
  methods: {
    getCategories: function () {
      axios.get("/api/get_categories").then(
        function (response) {
          this.categories = response.data;
        }.bind(this)
      );
    },
    onFileChange(e) {
      //console.log(e.target.files[0]);
      this.image = e.target.files[0].name;
      this.file = e.target.files[0];
    },
    store() {
      axios
        .post("/api/createproduit", {
          // /api/createproduit = au chemin depuis route -> api.php
          nom: this.nom,
          description: this.description,
          prix: this.prix,
          type: this.type,
          image: this.image,
          categories_id: this.categories_id,
          users_id: document
            .querySelector("meta[name='users_id']")
            .getAttribute("content"),
          headers: {
            "content-type": "multipart/form-data",
            "X-CSRF-TOKEN": document.querySelector('meta[name="csrf-token"]')
              .content,
          },
        })
        .then((response) => {
          this.produits = response.data.data;
          this.loading = false;
          this.form.reset();
          window.location = response.data.redirect;
        })
        .then(location.reload())
        .catch(function (error) {
          console.log(error);
        });
    },
  },
  mounted() {
    this.getCategories();
  },
};
</script>

<style></style>

Thank you in advance for your help.

Activity icon

Replied to Can't Display Image On Bootstrap-vue Datable

@marianomoreyra when i use this code

<div
	v-for="produit in items"
	class="card"
	v-bind:key="produit.id"
>
<img
	 v-on:click="info(row.item, row.index, $event.target)"
	 v-bind="mainProps"
	 center
	 :src="'/storage/uploads/produits/' + fields.image"
	 alt="Center image"
/>

</div>

the system loads the images, but do it slowly and reloads the page every 30s. I know this is not the right method so I had to give up this route. I am very new to Vuejs and have never rowed so much to learn a framework. Otherwise from my code how can you help me correct it to improve and finally display the images. Thank you in advance

Dec
22
3 months ago
Activity icon

Replied to Laravel 8 Vuejs Image Doesn't Upload And Save To Database

@hdsavani No error is generated, the system saves the data well, but does not save the image.

Dec
21
3 months ago
Activity icon

Replied to Laravel 8 Vuejs Image Doesn't Upload And Save To Database

@hdsavani thank you very much for the tutorial, but it doesn't work for me.

Activity icon

Replied to Pagination Doesn't Work

@rod2rick , thank you very much, by the way, what is the diffrenec between mounted and method ?

Activity icon

Replied to Pagination Doesn't Work

@marianomoreyra , thank you it's work..

Activity icon

Replied to Pagination Doesn't Work

@marianomoreyra, so what do you advice me please ?

Activity icon

Started a new Conversation Pagination Doesn't Work

Hello, i trying to paginate my bootstrap-vue Datatable, but some how the pagintion doesn't work. After looking well it seems that my array items [] is the problem and the this why the pagination stay to page 1.

Her is the full code :

<b-pagination
                        v-model="currentPage"
                        :total-rows="totalRows"
                        :per-page="perPage"
                        align="fill"
                        size="sm"
                      ></b-pagination>
<b-table
                      :striped="striped"
                      :bordered="bordered"
                      :borderless="borderless"
                      :outlined="outlined"
                      :sort-by.sync="sortBy"
                      :sort-desc.sync="sortDesc"
                      :current-page="currentPage"
                      :per-page="perPage"
                      :filter="filter"
                      :small="small"
                      :hover="hover"
                      :dark="dark"
                      :fixed="fixed"
                      :foot-clone="footClone"
                      :no-border-collapse="noCollapse"
                      :items="items"
                      :fields="fields"
                      :head-variant="headVariant"
                      :table-variant="tableVariant"
                    >
                      <template #cell(image)="row">
                        <div>
                          <b-img
                            v-on:click="info(row.item, row.index, $event.target)"
                            v-bind="mainProps"
                            center
                            :src="'/uploads/produits/' + fields.image"
                            alt="Center image"
                          ></b-img>
                        </div>
                      </template>
                      <template #cell(edit)="row">
                        <button
                          class="btn btn-sm btn-outline-info"
                          v-on:click="info(row.item, row.index, $event.target)"
                        >
                          <i class="fas fa-pen"></i>
                        </button>
                      </template>
                      <template #cell(delete)="row">
                        <button
                          class="btn btn-sm btn-outline-danger"
                          v-on:click="info(row.item, row.index, $event.target)"
                        >
                          <i class="fas fa-trash"></i>
                        </button>
                      </template>
                    </b-table>

<script>
import Vue from "vue";
import { BootstrapVue, IconsPlugin } from "bootstrap-vue";

// Install BootstrapVue
Vue.use(BootstrapVue);
// Optionally install the BootstrapVue icon components plugin
Vue.use(IconsPlugin);

export default {
  data() {
    return {
      filter: "",
      fields: [
        { key: "image", label: "" },
        { key: "nom", label: "Nom", sortable: true },
        {
          key: "description",
          label: "Description",
          sortable: true,
          sortDirection: "desc",
        },
        { key: "prix", label: "Prix", sortable: true },
        { key: "edit", label: "" },
        { key: "delete", label: "" },
      ],
      items: [],
      mainProps: {
          width: 55,
          height: 55,
          class: 'my-5'
        },
      tableVariants: [
        "primary",
        "secondary",
        "info",
        "danger",
        "warning",
        "success",
        "light",
        "dark",
      ],
      striped: false,
      bordered: false,
      borderless: false,
      outlined: false,
      small: false,
      hover: false,
      dark: false,
      fixed: false,
      footClone: false,
      headVariant: null,
      tableVariant: "",
      noCollapse: false,
      totalRows: 1,
      currentPage: 1,
      perPage: 5,
      pageOptions: [5, 10, 15, 25, 100, { value: 1000, text: "Tout" }],
      sortBy: "",
      sortDesc: false,
      sortDirection: "asc",
      filterOn: [],
    };
  },
  computed: {
    sortOptions() {
      // Create an options list from our fields
      return this.fields
        .filter((f) => f.sortable)
        .map((f) => {
          return { text: f.label, value: f.key };
        });
    },
  },
  mounted() {
    // Set the initial number of items
    this.totalRows = this.items.length;
  },
  methods: {
    getProduits: function () {
      axios.get("/api/listproduits").then(
        function (response) {
          this.items = response.data.data;
        }.bind(this)
      );
    },
    onFiltered(filteredItems) {
      // Trigger pagination to update the number of buttons/pages due to filtering
      this.totalRows = filteredItems.length;
      this.currentPage = 1;
    },
  },
  created: function () {
    this.getProduits();
  },
  mounted() {
    // Set the initial number of items
    this.totalRows = this.items.length;
  },
};
</script>

How can i solve this problem. Thank you in advance for the help.

Activity icon

Started a new Conversation Can't Display Image On Bootstrap-vue Datable

Hello, i can't display the image on my Bootstrap-vue Datable here is my code

<b-table
                      :striped="striped"
                      :bordered="bordered"
                      :borderless="borderless"
                      :outlined="outlined"
                      :sort-by.sync="sortBy"
                      :sort-desc.sync="sortDesc"
                      :current-page="currentPage"
                      :per-page="perPage"
                      :filter="filter"
                      :small="small"
                      :hover="hover"
                      :dark="dark"
                      :fixed="fixed"
                      :foot-clone="footClone"
                      :no-border-collapse="noCollapse"
                      :items="items"
                      :fields="fields"
                      :head-variant="headVariant"
                      :table-variant="tableVariant"
                    >
                      <template #cell(image)="row">
                        <div>
                          <b-img
                            v-on:click="info(row.item, row.index, $event.target)"
                            v-bind="mainProps"
                            center
                            :src="'/uploads/produits/' + fields.image"
                            alt="Center image"
                          ></b-img>
                        </div>
                      </template>
                      <template #cell(edit)="row">
                        <button
                          class="btn btn-sm btn-outline-info"
                          v-on:click="info(row.item, row.index, $event.target)"
                        >
                          <i class="fas fa-pen"></i>
                        </button>
                      </template>
                      <template #cell(delete)="row">
                        <button
                          class="btn btn-sm btn-outline-danger"
                          v-on:click="info(row.item, row.index, $event.target)"
                        >
                          <i class="fas fa-trash"></i>
                        </button>
                      </template>
                    </b-table>

<script>
import Vue from "vue";
import { BootstrapVue, IconsPlugin } from "bootstrap-vue";

// Install BootstrapVue
Vue.use(BootstrapVue);
// Optionally install the BootstrapVue icon components plugin
Vue.use(IconsPlugin);

export default {
  data() {
    return {
      filter: "",
      fields: [
        { key: "image", label: "" },
        { key: "nom", label: "Nom", sortable: true },
        {
          key: "description",
          label: "Description",
          sortable: true,
          sortDirection: "desc",
        },
        { key: "prix", label: "Prix", sortable: true },
        { key: "edit", label: "" },
        { key: "delete", label: "" },
      ],
      items: [],
      mainProps: {
          width: 55,
          height: 55,
          class: 'my-5'
        },
      tableVariants: [
        "primary",
        "secondary",
        "info",
        "danger",
        "warning",
        "success",
        "light",
        "dark",
      ],
      striped: false,
      bordered: false,
      borderless: false,
      outlined: false,
      small: false,
      hover: false,
      dark: false,
      fixed: false,
      footClone: false,
      headVariant: null,
      tableVariant: "",
      noCollapse: false,
      totalRows: 1,
      currentPage: 1,
      perPage: 5,
      pageOptions: [5, 10, 15, 25, 100, { value: 1000, text: "Tout" }],
      sortBy: "",
      sortDesc: false,
      sortDirection: "asc",
      filterOn: [],
    };
  },
  computed: {
    sortOptions() {
      // Create an options list from our fields
      return this.fields
        .filter((f) => f.sortable)
        .map((f) => {
          return { text: f.label, value: f.key };
        });
    },
  },
  mounted() {
    // Set the initial number of items
    this.totalRows = this.items.length;
  },
  methods: {
    getProduits: function () {
      axios.get("/api/listproduits").then(
        function (response) {
          this.items = response.data.data;
        }.bind(this)
      );
    },
    onFiltered(filteredItems) {
      // Trigger pagination to update the number of buttons/pages due to filtering
      this.totalRows = filteredItems.length;
      this.currentPage = 1;
    },
  },
  created: function () {
    this.getProduits();
  },
  mounted() {
    // Set the initial number of items
    this.totalRows = this.items.length;
  },
};
</script>

What did i make wrong so that the image can't be dislay. Thank you for the help.

Dec
19
3 months ago
Activity icon

Awarded Best Reply on Cant Run Vuejs Pages Without Internet.

I found the solution. I importe the file cdn\jsdelivr... vue.js in a local js folder and now I can run thé project without internet. Thank you for the help

Activity icon

Replied to Cant Run Vuejs Pages Without Internet.

I found the solution. I importe the file cdn\jsdelivr... vue.js in a local js folder and now I can run thé project without internet. Thank you for the help

Activity icon

Replied to Cant Run Vuejs Pages Without Internet.

Yes only for jsdelivr, and before yesterday I was using it and my project was running well without internet. I just install bootstrap-vue and datatable-vue Since 2 days.

Activity icon

Started a new Conversation Cant Run Vuejs Pages Without Internet.

Hi, Since yesterday I cant run any Vuejs page without internet. I can only run blade pages in offline mode. Can someone help me so that I can use my projet without internet. Thank you.

Dec
18
3 months ago
Activity icon

Awarded Best Reply on WARNING In ./resources/js/app.js :"export 'VueRouter' Was Not Found In 'vue-router'

I had the solution to my problem. i had not set up the dependency of bootstrap-vue properly, it was in my package.jason, but not the dependency file, I had to install it via npm install bootstrap-vue. Thank you very much for your help.

Activity icon

Replied to WARNING In ./resources/js/app.js :"export 'VueRouter' Was Not Found In 'vue-router'

I had the solution to my problem. i had not set up the dependency of bootstrap-vue properly, it was in my package.jason, but not the dependency file, I had to install it via npm install bootstrap-vue. Thank you very much for your help.

Dec
15
3 months ago
Activity icon

Replied to WARNING In ./resources/js/app.js :"export 'VueRouter' Was Not Found In 'vue-router'

I still can't get the answer can someone help me ?

Activity icon

Replied to WARNING In ./resources/js/app.js :"export 'VueRouter' Was Not Found In 'vue-router'

i have try this and nothing but the same error

Activity icon

Replied to WARNING In ./resources/js/app.js :"export 'VueRouter' Was Not Found In 'vue-router'

@maverickchan i have change things like you suggest but and the same error was reported on the route.js file

"export 'VueRouter' was not found in 'vue-router'
 @ multi ./resources/js/app.js ./resources/sass/app.scss ./resources/sass/style.scss```