1570214743
Hello
how I can generate unique ID in laravel?
dont say uuid becouse it is too long!
I need create 9 char numbers only or it is okay if generate numbers and letter but not more 10 char
thanks
#laravel #php
1624255260
Today, we will see Laravel 8 PDF Generate Example.
For generating PDF file we will use Laravel-dompdf package, it is create pdf file and also provide to download file functionalities it is very easy to generate pdf in laravel 8, i will give you example in very simple way to generate pdf file and download in your system.
So, Let’s start and see how to generate pdf in laravel 8.
#laravel 8 pdf generate example #laravel 8 #pdf generate #generate pdf in laravel 8 #laravel-dompdf package #how to generate pdf in laravel 8
1597817005
Bar Code Generate in Laravel 7, 6. In this post, i will show you simple and easy steps to generate bar/qr code in laravel.
Use the below given steps and generate bAR/QR codes in laravel Projects:
https://www.tutsmake.com/laravel-6-simple-generate-or-create-qr-codes-example/
#laravel 7 bar code generator #barcode generator laravel 7 #barcode generator laravel 6 #laravel 7 qr code generator #laravel simple/barcode example
1595201363
First thing, we will need a table and i am creating products table for this example. So run the following query to create table.
CREATE TABLE `products` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`description` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
`updated_at` datetime DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
Next, we will need to insert some dummy records in this table that will be deleted.
INSERT INTO `products` (`name`, `description`) VALUES
('Test product 1', 'Product description example1'),
('Test product 2', 'Product description example2'),
('Test product 3', 'Product description example3'),
('Test product 4', 'Product description example4'),
('Test product 5', 'Product description example5');
Now we are redy to create a model corresponding to this products table. Here we will create Product model. So let’s create a model file Product.php file under app directory and put the code below.
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Product extends Model
{
protected $fillable = [
'name','description'
];
}
Now, in this second step we will create some routes to handle the request for this example. So opeen routes/web.php file and copy the routes as given below.
routes/web.php
Route::get('product', 'ProductController@index');
Route::delete('product/{id}', ['as'=>'product.destroy','uses'=>'ProductController@destroy']);
Route::delete('delete-multiple-product', ['as'=>'product.multiple-delete','uses'=>'ProductController@deleteMultiple']);
#laravel #delete multiple rows in laravel using ajax #laravel ajax delete #laravel ajax multiple checkbox delete #laravel delete multiple rows #laravel delete records using ajax #laravel multiple checkbox delete rows #laravel multiple delete
1611751945
In this tutorial i will show you how to generate barcode using milon/barcode package. In this example we will use milon/barcode package and we will implement it in our laravel barcode example. milon/barcode package provide many functionalities and diffrent options to generate barcode, It’s provide several barcode like C39E,Qr Code, C39, C39E+, C93, S25,S25+, C39+, I25,I25+, PDF417 etc…
So, Let’s start and follow below step to get output.
Thanks for Reading !!
#create #generate #barcode #laravel #how to generate barcode in laravel #barcode generator
1595216280
Some times there are cases where you want to get relationship from relationship in Laravel, that can be achieved via following:
Account::with(['profiles','profiles.products'])->get();
Sometimes you want to apply multiple where clauses in a single query like that:
$results = User::where('this', '=', 1)
->where('that', '=', 1)
->where('this_too', '=', 1)
->where('that_too', '=', 1)
->where('this_as_well', '=', 1)
->where('that_as_well', '=', 1)
->where('this_one_too', '=', 1)
->where('that_one_too', '=', 1)
->where('this_one_as_well', '=', 1)
->where('that_one_as_well', '=', 1)
->get();
This can be achieved using single where clause by following code:
$query->where([
['column_1', '=', 'value_1'],
['column_2', '<>', 'value_2'],
[COLUMN, OPERATOR, VALUE]
])
The are situations, during bulk insertion or single row insertion you may want to retrieve last inserted id, can be achieved by following:
$post = Input::All();
$data = new Company;
$data->nombre = $post['name'];
$data->direccion = $post['address'];
$data->telefono = $post['phone'];
$data->email = $post['email'];
$data->giro = $post['type'];
$data->fecha_registro = date("Y-m-d H:i:s");
$data->fecha_modificacion = date("Y-m-d H:i:s");
$data->save();
//getting last inserted id
$data->id;
Sometimes you want to add a custom attribute in model during load, this can be achieved by following code:
class Book extends Eloquent {
protected $table = 'books';
public function toArray()
{
$array = parent::toArray();
$array['upper'] = $this->upper;
return $array;
}
public function getUpperAttribute()
{
return strtoupper($this->title);
}
}
#laravel #php #how to add a custom attribute in laravel during model load #how to create multiple where clauses in single where clause in laravel #how to get a specific column using with() in laravel #how to get last inserted id in laravel #how to get relationship from relationship laravel #laravelfaq