how to upload spatie laravel stored backup to google drive? - laravel

i am trying to upload backup on google drive using laravel spatie package i followed these steps
https://gist.github.com/sergomet/f234cc7a8351352170eb547cccd65011
my backup is created successfully g-drive is integrated successfully but when perform action backup:run it gives this error mostly file not found and in the last it says
backup failed because: unlink C:\xampp\htdocs\newfolder\storage\app/backup-temp\temp\2020-11-07-20-06-19.zip) resource temporarily unavailable
and here is my config/backup.php
<?php
return [
'backup' => [
'name' => config('GOOGLE_DRIVE_FOLDER_ID' , 'laravel-backup'),
'source' => [
'files' => [
'include' => [
],
'exclude' => [
base_path('vendor'),
base_path('node_modules'),
],
'followLinks' => false,
],
'databases' => [
'mysql',
],
],
'database_dump_compressor' => null,
'destination' => [
'filename_prefix' => '',
'disks' => [
'local' , 'google'
],
],
'temporary_directory' => storage_path('app/backup-temp'),
],
'notifications' => [
'notifications' => [
\Spatie\Backup\Notifications\Notifications\BackupHasFailed::class => ['mail'],
\Spatie\Backup\Notifications\Notifications\UnhealthyBackupWasFound::class => ['mail'],
\Spatie\Backup\Notifications\Notifications\CleanupHasFailed::class => ['mail'],
\Spatie\Backup\Notifications\Notifications\BackupWasSuccessful::class => ['mail'],
\Spatie\Backup\Notifications\Notifications\HealthyBackupWasFound::class => ['mail'],
\Spatie\Backup\Notifications\Notifications\CleanupWasSuccessful::class => ['mail'],
],
'notifiable' => \Spatie\Backup\Notifications\Notifiable::class,
'mail' => [
],
'slack' => [
'webhook_url' => '',
'channel' => null,
'username' => null,
'icon' => null,
],
],
'monitorBackups' => [
[
'name' => env('GOOGLE_DRIVE_FOLDER_ID' , 'laravel-backup'),
'disks' => ['local'],
'newestBackupsShouldNotBeOlderThanDays' => 1,
'storageUsedMayNotBeHigherThanMegabytes' => 5000,
],
],
'cleanup' => [
'strategy' => \Spatie\Backup\Tasks\Cleanup\Strategies\DefaultStrategy::class,
'defaultStrategy' => [
'keepAllBackupsForDays' => 7,
'keepDailyBackupsForDays' => 16,
'keepWeeklyBackupsForWeeks' => 8,
'keepMonthlyBackupsForMonths' => 4,
'keepYearlyBackupsForYears' => 2,
'deleteOldestBackupsWhenUsingMoreMegabytesThan' => 5000,
],
],
];
my .env
GOOGLE_DRIVE_CLIENT_ID=183462809528-gqhvm96rpsvhccp4lll55soms.apps.googleusercontent.com
GOOGLE_DRIVE_CLIENT_SECRET=T7OaNoN5t2GBHU4hvBVKX
GOOGLE_DRIVE_REFRESH_TOKEN="1//04Z70eIYBuRvgCgYIARAAGAQSNwF-L9Ir1riNcqKpwiOYeFdP6LlXhpcRgDPiMLbZvZS0UKQtDrEpqizRpLwah-Y2-WdmOs"
GOOGLE_DRIVE_FOLDER_ID=1245H1fYLxa8q0LJD1uTAe-chX8W44ALJ

To fix this error set the name to an empty string in the config/backup.php.
'name' => '',
In the following video link, the solution to this error is explained in detail:
https://www.youtube.com/watch?v=6kxXkrlRuJU
I am sure it will be helpful. Or you can also check out the article on -
How To Setup Laravel Backup On Google Drive?

Related

scout:import appends numbers to elasticsearch index name

I'm using the matchish/laravel-scout-elasticsearch package and when I run php artisan scout:import on a model the index that gets created has a timestamp appended to it.
For example my config and searchableAs() method on the model returns 'groups' however the index that is created is 'groups_1632322111'. The appended timestamp updates on subsequent imports.
Is there a way to prevent the timestamp from being added?
Here is my config:
<?php
return [
'host' => env('ELASTICSEARCH_HOST'),
'indices' => [
'mappings' => [
'default' => [
'properties' => [
'id' => [
'type' => 'keyword',
],
],
],
'events' => [
'properties' => [
'id' => [
'type' => 'keyword'
]
]
],
'groups' => [
'properties' => [
'id' => [
'type' => 'keyword'
]
]
]
],
'settings' => [
'default' => [
'number_of_shards' => 1,
'number_of_replicas' => 0,
],
],
],
];

How can I configure doctrine with migrations?

I have this problem when I try to generate a migration from the terminal. How can I configure doctrine with migration?
https://i.ibb.co/HqWYBdT/imagen.png
'doctrine' => [
'migrations_configuration' => [
'orm_default' => [
'table_storage' => [
'table_name' => 'migrations',
'version_column_name' => 'version',
'version_column_length' => 1024,
'executed_at_column_name' => 'executedAt',
'execution_time_column_name' => 'executionTime',
],
'migrations_paths' => [
'Migrations' => 'data/Migrations',
], // an array of namespace => path
'migrations' => [], // an array of fully qualified migrations
'all_or_nothing' => false,
'check_database_platform' => true,
'organize_migrations' => 'none', // year or year_and_month
'custom_template' => null,
],
],
],

pwa Laravel don't give me error in console but error in service workers in Cache

this first time to make PWA, I make everything like https://github.com/silviolleite/laravel-pwa and all thing is good in console but make error in manifest and service workers
my path project is :
_config
|_laravelpwa.php
_resources
|_views
|_vendor
|_laravelpwa
|_meta.blade.php
_index.php
_serviceworker.js
meta.blade.php all same expect
<script type="text/javascript">
// Initialize the service worker
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/serviceworker.js', {
scope: '.'
}).then(function (registration) {
// Registration was successful
console.log('Laravel PWA: ServiceWorker registration successful with scope: ', registration.scope);
}, function (err) {
// registration failed :(
console.log('Laravel PWA: ServiceWorker registration failed: ', err);
});
}
</script>
laravelpwa.php
<?php
return [
'name' => 'baskotii',
'manifest' => [
'name' => 'baskotii',
'short_name' => 'baskotii',
'start_url' => '/',
'background_color' => '#ffffff',
'theme_color' => '#000000',
'display' => 'standalone',
'orientation'=> 'any',
'status_bar'=> 'black',
'icons' => [
'72x72' => [
'path' => asset('assets/front/img/logo72.png'),
'purpose' => 'any'
],
'96x96' => [
'path' => '/public/images/icons/icon-96x96.png',//asset('assets/front/img/logo96.png'),
'purpose' => 'any'
],
'128x128' => [
'path' => asset('assets/front/img/logo128.png'),
'purpose' => 'any'
],
'144x144' => [
'path' => asset('assets/front/img/logo144.png'),
'purpose' => 'any'
],
'152x152' => [
'path' => asset('assets/front/img/logo152.png'),
'purpose' => 'any'
],
'192x192' => [
'path' => asset('assets/front/img/logo192.png'),
'purpose' => 'any'
],
'384x384' => [
'path' => asset('assets/front/img/logo384.png'),
'purpose' => 'any'
],
'512x512' => [
'path' => asset('assets/front/img/logo512.png'),
'purpose' => 'any'
],
],
'splash' => [
'640x1136' => '/images/icons/splash-640x1136.png',
'750x1334' => '/images/icons/splash-750x1334.png',
'828x1792' => '/images/icons/splash-828x1792.png',
'1125x2436' => '/images/icons/splash-1125x2436.png',
'1242x2208' => '/images/icons/splash-1242x2208.png',
'1242x2688' => '/images/icons/splash-1242x2688.png',
'1536x2048' => '/images/icons/splash-1536x2048.png',
'1668x2224' => '/images/icons/splash-1668x2224.png',
'1668x2388' => '/images/icons/splash-1668x2388.png',
'2048x2732' => '/images/icons/splash-2048x2732.png',
],
'shortcuts' => [
[
'name' => 'baskotii',
'description' => 'baskotii',
'url' => '/',
'icons' => [
"src" => '/public/images/icons/icon-96x96.png',
"purpose" => "any"
]
]
],
'custom' => []
]
];
I use my img and default img and make the same warning
the Result:
console
Laravel PWA: ServiceWorker registration successful with scope: https://baskotii.ae/
and this in serviceworker.js:1
Uncaught (in promise) TypeError: Failed to execute 'Cache' on 'addAll': Request failed
manifest warning
service workers error
Try with update URL in serviceworker.js
Like this
var filesToCache = [
'css/app.css',
'js/app.js',
'images/icons/icon-72x72.png',
'images/icons/icon-96x96.png',
'images/icons/icon-128x128.png',
'images/icons/icon-144x144.png',
'images/icons/icon-152x152.png',
'images/icons/icon-192x192.png',
'images/icons/icon-384x384.png',
'images/icons/icon-512x512.png',
];

Issue setting new Yii2 theme on basic template

I have downloaded and set the theme according to the Themefactory site and other SO posts but the theme is just loading as pure html. Meaning that there is no formatting, just text and links.
This is my code in the web.php file in the config directory:
<?php
$params = require(__DIR__ . '/params.php');
$config = [
'id' => 'basic',
'basePath' => dirname(__DIR__),
'bootstrap' => ['log'],
'components' => [
'view' => [
'class' => 'yii\web\View',
'theme' => [
'class' => 'yii\base\dorian',
'pathMap' => ['#app/views' => 'themes/dorian'],
'baseUrl' => 'themes/dorian'
],
],
'request' => [
// !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
'cookieValidationKey' => 'KecrcGLWURmyPrWp3QBgYuOQ21JuCFA1',
],
'cache' => [
'class' => 'yii\caching\FileCache',
],
'user' => [
'identityClass' => 'app\models\User',
'enableAutoLogin' => true,
Screenshot of file tree: http://prntscr.com/9708gi
Does anyone see anything wrong???
try
'components' => [
'view' => [
'theme' => [
'basePath' => '#app/themes/tf-dorian',
'pathMap' => [
'#app/views' => '#app/themes/tf-dorian',
],
'baseUrl' => '#web/',
],
],
please try this and let me know if it doesn't work:
'view' => [
'class' => 'yii\web\View',
'theme' => [
'class' => 'yii\base\Theme',
'pathMap' => ['#app/views' => 'themes/tf-dorian'],
'baseUrl' => 'themes/tf-dorian'
]
]
Thanks. I figured it out. The themes directory had to go under the "web" directory.

Yii2 Advanced app, different session for frontend and backend with subdomains

I have a problem with my Yii2 app.
I have a advanced-app with frontend and backend parts on different domains (subdomain). I use webvimark user management module, but I think the problem is not in it.
Frontend app -> domain.com
Backend app -> admin.domain.com
So I have problem with login in backend, it is not working.
I enter login and password, and after submit form I see login form again.
'user' => [
'identityClass' => 'webvimark\modules\UserManagement\models\User',
'enableAutoLogin' => true,
'identityCookie' => [
'name' => '_backendIdentity',
'domain' => 'admin.domain.com',
],
'class' => 'webvimark\modules\UserManagement\components\UserConfig',
],
and
'session' => [
'name' => 'BACKENDSESSID',
'cookieParams' => [
'domain' => 'admin.domain.com',
],
],
Any ideas?
Update #1: My config located: /backend/config/main.php
Update #2: There was a problem when transferring backend on a subdomain
Okey, there was a problem with the configuration of the module, as well as the wrong config in the frontend.
Backend:
'user' => [
'identityClass' => 'webvimark\modules\UserManagement\models\User',
'enableAutoLogin' => true,
'identityCookie' => [
'name' => '_backendIdentity',
'domain' => 'backend.test.dev',
],
'class' => 'webvimark\modules\UserManagement\components\UserConfig',
'on afterLogin' => function ($event) {
\webvimark\modules\UserManagement\models\UserVisitLog::newVisitor($event->identity->id);
},
],
'session' => [
'name' => 'BACKENDSESSID',
'cookieParams' => [
'domain' => 'backend.test.dev',
],
],
Frontend:
'user' => [
'identityClass' => 'webvimark\modules\UserManagement\models\User',
'enableAutoLogin' => true,
'identityCookie' => [
'name' => '_frontendIdentity',
'path' => '/',
],
'class' => 'webvimark\modules\UserManagement\components\UserConfig',
'on afterLogin' => function ($event) {
\webvimark\modules\UserManagement\models\UserVisitLog::newVisitor($event->identity->id);
}
],
'session' => [
'name' => 'FRONTENDSESSID',
'cookieParams' => [
'path' => '/',
],
],

Resources