Posts

Showing posts with the label laravel

Download pdf by ajax or javascript or angular js

Click on button for generate pdf  $("#print_selected_label").on("click", function(){    data = []    $("input:checkbox.print_label:checked").each(function(){      data.push($(this).attr("id"));    });   //getting all information of checked checkbox    if(data.length > 0){    // if data is not null       In angular js controller         // var redirect_new = "/admin/v2/orders/print_multiple_label.pdf?" + jQuery.param(data);        // var pdf = window.open(redirect_new, 'Map PDF', '');      By Creating a link by javascript       // var mydiv = document.getElementById("download_pdf");      // var aTag = document.createElement('a');      // var link = " admin/v2/orders/print_multiple_label.pdf?id="+data ;      // aTag.setAttribute('href',link);      // aTag.innerHTML = "link text";      // mydiv.appendChild(aTag);      // aTag.click(); By making http request    

how to delete associated record in laravel

There are two ways to delete associated record or related record. First way is  Suppose we have two models Category and Product. we have association like category has many products. our Category model like this class Category extends Model {     /**      * Get the comments for the blog post.      */     public function products()     {         return $this->hasMany('App\Product', 'category_id');     } } our Product model like this class Product extends Model {     /**      * Get the comments for the blog post.      */     public function category()     {         return $this->belongsTo('App\Category');     } } so write this in your category model. public static function boot() {         parent::boot();         static::deleting(function($category) { // before delete() method call this              $category->products()->delete();              // do the rest of the cleanup.

Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes (SQL: alter table `users` add unique `users_email_unique`(`email`))

use Illuminate\Support\Facades\Schema;  public function boot()   {      Schema::defaultStringLength(191);    }

laravel: command not found

export PATH="$HOME/.composer/vendor/bin:$PATH" source ~/.bash_profile

send data to view from controller in laravel

There are many ways to send data to views from controller i am assuming $data you have to send in view return view('layout',['data' => $data]); return view('layout',compact('data'));  return view('layout')->with(compact('data'));  return view('layout')->withData($data);  return view('layout')->with('data',$data);

Base table or view not found: 1146 Table 'links.blogs' doesn't exist

make sure you are using create instead of table. use Schema::create to create new. Schema::create('links', function (Blueprint $table) {       $table->increments('id');       $table->timestamps(); }); some this like this

create table through migration in laravel

php artisan make:migration create_YOUR_TABLE_NAME_table --create=YOUR_TABLE_NAME For example i am creating links table php artisan make:migration create_links_table --create=links this command will generate migration like this Schema::create('links', function (Blueprint $table) {       $table->increments('id');       $table->timestamps(); });

Laravel Error 500 Whoops, looks like something went wrong – Exception

php artisan key:generate generate key php artisan config:clear clear project cache php artisan config:cache php artisan serve start server again

my input a=12, but how do I print this in 3 digits?

There are many ways to do this. I am using the simplest way to print two digit number in three digit number. import java . util . Scanner ; class Digit { public static void main ( String [] args ) { Scanner sc = new Scanner ( System . in ); System . out . println ( "please enter any two digit number:" ); int n = sc . nextInt (); int k = 0 ; if ( n > 9 && n < 100 ) { k = n * 10 ; } else { System . out . println ( "please enter any two digit number:" ); } System . out . println ( "you entered " + n + " and three digit output of this number is " + k ); } Read More

Header Function || How to Redirect in php

Header Function || How to Redirect in php Header is a fuction which is used to Redirect current page to specified page. syntax. 1).header(‘Location: specified_page_name ’); 2).header(“refreash;1;url= specified_page_name ”);       2nd statement takes you on specified page after 1 second.