PHP code example of elipzis / laravel-pastable-model
1. Go to this page and download the library: Download elipzis/laravel-pastable-model 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/ */
elipzis / laravel-pastable-model example snippets
return [
//The default cut&paste chunk size (limit)
'chunkSize' => 1000,
//Auto-create tables, if not existing
'autoCreate' => false,
//Enable detailed logging to any accepted and configured level
'logging' => [
'enabled' => false,
'level' => null,
],
];
...
use ElipZis\Pastable\Models\Traits\CopyPastable;
...
class YourModel extends Model {
use CopyPastable;
...
...
use ElipZis\Pastable\Models\Traits\CutPastable;
...
class YourModel extends Model {
use CutPastable;
...
...
class YourModel extends Model {
...
protected string $pastableTable = 'log_something';
...
...
class YourModel extends Model {
...
public function getPastableTable(): string
{
return 'log_something_' . Carbon::now()->format('Y_m_d');
}
...
...
class YourModel extends Model {
...
public function getPastableQuery(): Builder
{
return static::query()->where('created_at', '<=', now()->subDay());
}
...
...
class YourModel extends Model {
...
protected string $pastableConnection = 'logging';
...
namespace App\Console;
...
use ElipZis\Pastable\Jobs\PastableJob;
...
class Kernel extends ConsoleKernel
...
protected function schedule(Schedule $schedule)
{
...
$schedule->job(PastableJob::class)->daily();
...
}
...
...
use ElipZis\Pastable\Jobs\PastableJob;
...
class YourClass
...
protected function yourFunction()
{
...
PastableJob::dispatch();
...
}
...