Skip to main content

Posts

Adding bootstrap to Vue Error (Can not resolve jquery)

 Error: These dependencies were not found: * jquery in ./node_modules/bootstrap/dist/js/bootstrap.js * popper.js in ./node_modules/bootstrap/dist/js/bootstrap.js Solution:  run the following code to install jquery and popper using npm. npm install --save jquery popper.js Then, npm install bootstrap And import bootstrap in main.js like this: import   'bootstrap' ;

Call to a member function map() on array

 I have faced this when i have used: return    $request -> clients -> map ( function ( $client ){              return   $client ;         }); it showed Call to a member function map() on array error. So to solve this I have used:  return    collect ( $request -> clients )-> map ( function ( $client ){              return   $client ;         });

Call to a member function middleware() on null

 In web.php I the following routes: web.php Route :: prefix ( 'app' )-> group ( function (){      Route :: post ( '/create_tag' , 'AdminController@addTag' ); })-> middleware ( AdminCheck :: class ); Here, middleware is AdminCheck. and in my AdminCheck middleware I wrote the following to test the middleware: AdminCheck.php   public   function   handle ( $request ,  Closure   $next )     {          if (! Auth :: check ())         {              return   'not loggedIn' ;         }          return   $next ( $request );     } Now when I reload the '/' url of the website it shows 'Call to a member function middleware() on null'  error. To solve this:  In web...

Object of class App\Invoice could not be converted to int

 In my case I was doing this: <?php $getallinvoiceids  = \App\ Invoice :: all (); echo   'in' . '-' . sprintf ( '%06d' , $getallinvoiceids -> last ()-> id + 1 ); ?> So,  $getallinvoiceids -> last ()-> id + 1  was giving me the error of  App\Invoice could not be converted to int. as it was searching for the last data but the invoices table was empty.  Now to solve this, first we need to count the table then do the operation. Like: <?php         $getallinvoiceids  = \App\ Invoice :: all ();       if ( $getallinvoiceids -> count () <=  0 )      {          $rowcount  =  1 ;      }       else      {          $rowcount  =  $getallinvoiceids -> last ()-...

Laravel Vue Basic (Use of Vue Router)

 Vue Router Documentation: https://router.vuejs.org/installation.html 1) In terminal run the command:  npm install vue-router 2) As we will have many routes, so we will make a new file for that inside resources -> js create router.js file. 3) Open router.js file and import Vue & Router: import   Vue   from   'vue' import   Router   from   'vue-router' Now, we will use the route. So, in router.js file: Vue . use ( Router ) const   routes  = [     {          path :   '/my-new-vue-route' ,          component :       } ]; Here, we have given a path url name (you can give anything as url name). and the component is blank. we will first make a folder called pages inside resources -> js -> components .  and, create a file inside pages folder called  myFirstVuePage.vue . 4) Inside ...

Laravel Vuejs Basic Setup

In this article we will see how to setup vue with laravel. 1) Create a laravel project: laravel new laravue 2) In web.php create a temporary route:  Route :: get ( '/test' ,  function  () {      return   view ( 'welcome' ); }); So, when you will see the welcome page once you hit the  http://laravue.test/test  url. 2) In terminal run:  npm install 3) npm install vue (In package.json file you will see that vue dependency has been added successfully) 4) Now go to resources -> js -> app.js file. Here we will have to load the vue. write the following lines in app.js.  require ( './bootstrap' ); window . Vue  =  require ( 'vue' ); const   app  =  new   Vue ({      el :   '#app' }); (Here, vue js will execute and control anything that will be inside the app id. So, for our example  let's put the app id inside the welcome view). So, inside welcome.blade.php 's body...