Category: Programming

Laravel Export to PDF using Dompdf

Step 1: Create Table using migration php artisan make:migration create_students_table <?php use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; class CreateStudentsTable extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::create('students', function (Blueprint $table) { $table->id(); $table->string('first_name'); $table->string('last_name'); $table->text('address'); $table->timestamps(); }); } /** * Reverse the migrations. * * … Continue reading Laravel Export to PDF using Dompdf

Export Data to Excel File in Laravel

Install php spreadsheet via composer composer require phpoffice/phpspreadsheet Step1: Create Database Table CREATE TABLE `emp` ( `id` int(11) NOT NULL, `name` varchar(255) NOT NULL, `skills` varchar(255) NOT NULL, `address` varchar(255) NOT NULL, `designation` varchar(255) NOT NULL, `age` int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 We will also insert few records to create example. INSERT INTO … Continue reading Export Data to Excel File in Laravel

Laravel simple API implementation

RESTful APIs First, we need to understand what exactly is considered a RESTful API. REST stands for REpresentational State Transfer and is an architectural style for network communication between applications, which relies on a stateless protocol (usually HTTP) for interaction. HTTP Verbs Represent Actions In RESTful APIs, we use the HTTP verbs as actions, and the endpoints … Continue reading Laravel simple API implementation

How to create sample data in Laravel (database seeder)

First you need to create table example $ php artisan make:model Article --migration Then it will create model with migration (table structure) then you need to create more columns for Article in this case I will add title and body as below <?php use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class CreateArticlesTable extends Migration { /** … Continue reading How to create sample data in Laravel (database seeder)

How to create mysql database with docker

1 install docker in your system 2 create file :  docker-compose.yml version: '3.3' services: db: image: mysql:5.7 restart: always environment: MYSQL_DATABASE: 'db' # So you don't have to use root, but you can if you like MYSQL_USER: 'user' # You can use whatever password you like MYSQL_PASSWORD: 'password' # Password for root access MYSQL_ROOT_PASSWORD: 'password' … Continue reading How to create mysql database with docker