Skip to main content

Posts

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...

The POST method is not supported for this route.

  The POST method is not supported for this route.  While updating a form you might face this error. That happens because of your form action method or the web route of that action. So, lets see the solutions. 1) If the method is update and the form action is like this: <form action="{{route('invoice.update', $invoice->id)}}" method="POST" enctype="multipart/form-data"> @csrf </form> and route of this: Route::patch('invoice/{id}','InvoiceController@update')->name('invoice.update'); Here, from the route we can see that this is a patch method. so, for patch method we need to write {{ method_field('patch') }}  between form. Example:  <form action="{{route('invoice.update', $invoice->id)}}" method="POST" enctype="multipart/form-data">  @csrf {{ method_field('patch') }} </form> 2) If we change the Route::patch to Route::post it will also work. ...

Datatable sort_both.png 404 not found

 Datatable showed vendors\datatables.net-dt sort_both.png 404 not found ! 1) This might cause due to the missing images folder in datatables.net-dt. So create an images folder. Now download these images and place them in the folder. 1)  2)  3) 

AJAX basic (get data)

*** At first go to xampp or any localserver create a database called samples and inside samples database create a table called student inside student table create id (primary key) int Auto increment, roll, name, address, stream, status of string type <? php include ( "connection.php" ); mysqli_select_db ( "samples" , $con ); $result = mysqli_query ( "select * from student" , $con ); echo "<table border='1' > <tr> <td align=center> <b>Roll No</b></td> <td align=center><b>Name</b></td> <td align=center><b>Address</b></td> <td align=center><b>Stream</b></td></td> <td align=center><b>Status</b></td>" ; while ( $data = mysqli_fetch_row ( $result )) { echo "<tr>" ; echo "<td align=center>$data[0]</td>" ; echo "<td align=center>$da...

dataTable in laravel without Yajra

Add this following link in the head tag of your project:  < link   rel = "stylesheet"   type = "text/css"   href = "https://cdn.datatables.net/1.10.21/css/jquery.dataTables.min.css" /> < div   class = "container" >          < div   class = "row" >              < div   class = "col-md-12" >                  < table   class = "table table-bordered"   id = "posts" >                      < thead >                              < th > Id </ th >       ...