PHP code example of underwear / laravel-excel-import
1. Go to this page and download the library: Download underwear/laravel-excel-import library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use Underwear\Import\Elements\Text;
Text::make('targetTableColumnName', 'A');
use Underwear\Import\Elements\Text;
Text::make('target_table_colum_name', 'A')
->rules(['filled', 'email']);
use Underwear\Import\Elements\Text;
Text::make('target_table_colum_name', 'A')
->prepare(function($value) {
return ucfirst($value);
});
use Underwear\Import\Elements\Slug;
Slug::make('slug', 'B');
use Underwear\Import\Elements\Boolean;
Boolean::make('is_published', 'D')
->trueValue('yeap');
use Underwear\Import\Elements\Autoincrement;
Autoincrement::make('order_column');
use Underwear\Import\Elements\BelongsTo;
BelongsTo::make('category_id', 'C', 'categories' , 'title', 'id');
// 3th arg: related table in database;
// 4th arg: column for searching in related table;
// 5th arg: column for value returning from related table;
use Underwear\Import\Elements\Closure;
Closure::make('some_table_field', function() {
// code here whatever you want
return "something";
});
use Underwear\Import\Elements\Faker;
use Faker\Generator;
Faker::make('some_table_field', function(Generator $faker) {
return $faker->word;
});
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.