1. Go to this page and download the library: Download samdevbr/laravel-bigreport 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 Illuminate\Database\Eloquent\Model;
class Post extends Model
{
protected $table = 'post';
public function author()
{
return $this->belongsTo(User::class);
}
}
use Samdevbr\Bigreport\Fields\FieldCollection;
use Samdevbr\Bigreport\Fields\BelongsTo;
use Samdevbr\Bigreport\Fields\Text;
$fields = [
Text::make('Post ID', 'id'),
Text::make('Title', 'title'),
Text::make('Description', 'description'),
BelongsTo::make('Author', 'author.name'),
];
$fieldCollection = FieldCollection::make($fields);
use Samdevbr\Bigreport\Fields\FieldCollection;
use Samdevbr\Bigreport\Fields\BelongsTo;
use Samdevbr\Bigreport\Fields\Text;
$fields = [
Text::make('Post ID', 'id'),
Text::make('Title', 'title'),
Text::make('Description', 'description', function ($description) {
return str_limit($description, 20);
}),
BelongsTo::make('Author', 'author.name'),
];
$fieldCollection = FieldCollection::make($fields);
use App\Post;
$export = Post::export($fieldCollection);
return $export->download('filename.csv');
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.