fixed default icons

This commit is contained in:
vedatakd 2021-04-16 07:11:51 +03:00
parent 008720db5e
commit 7d0409f9ad

View File

@ -10,6 +10,7 @@ use Anomaly\UrlLinkTypeExtension\UrlLinkTypeModel;
use Anomaly\UsersModule\Role\Contract\RoleRepositoryInterface; use Anomaly\UsersModule\Role\Contract\RoleRepositoryInterface;
use Anomaly\UsersModule\User\Contract\UserRepositoryInterface; use Anomaly\UsersModule\User\Contract\UserRepositoryInterface;
use Anomaly\UsersModule\User\UserActivator; use Anomaly\UsersModule\User\UserActivator;
use Illuminate\Console\Command;
use Illuminate\Database\Seeder; use Illuminate\Database\Seeder;
use Anomaly\DashboardModule\Widget\Contract\WidgetRepositoryInterface; use Anomaly\DashboardModule\Widget\Contract\WidgetRepositoryInterface;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
@ -20,144 +21,150 @@ use ZipArchive;
class DatabaseSeeder extends Seeder class DatabaseSeeder extends Seeder
{ {
protected $widgets; protected $widgets;
protected $menus; protected $menus;
protected $users; protected $users;
protected $roles; protected $roles;
protected $activator; protected $activator;
protected $disks; protected $disks;
protected $folders; protected $folders;
protected $command;
public function __construct( public function __construct(
WidgetRepositoryInterface $widgets, WidgetRepositoryInterface $widgets,
MenuRepositoryInterface $menus, MenuRepositoryInterface $menus,
UserRepositoryInterface $users, UserRepositoryInterface $users,
DiskRepositoryInterface $disks, DiskRepositoryInterface $disks,
FolderRepositoryInterface $folders, FolderRepositoryInterface $folders,
RoleRepositoryInterface $roles, RoleRepositoryInterface $roles,
UserActivator $activator UserActivator $activator,
) Command $command
{ )
$this->widgets = $widgets; {
$this->menus = $menus; $this->widgets = $widgets;
$this->users = $users; $this->menus = $menus;
$this->roles = $roles; $this->users = $users;
$this->activator = $activator; $this->roles = $roles;
$this->disks = $disks; $this->activator = $activator;
$this->folders = $folders; $this->disks = $disks;
} $this->folders = $folders;
$this->command = $command;
}
public function run() public function run()
{ {
$admin = $this->roles->findBySlug('admin'); $admin = $this->roles->findBySlug('admin');
$this->users->unguard(); $this->users->unguard();
$this->users->newQuery()->where('email', "info@openclassify.com")->forceDelete(); $this->users->newQuery()->where('email', "info@openclassify.com")->forceDelete();
$visiosoft_administrator = $this->users->create( $visiosoft_administrator = $this->users->create(
[ [
'first_name' => 'Dev', 'first_name' => 'Dev',
'last_name' => 'Openclassify', 'last_name' => 'Openclassify',
'display_name' => 'openclassify', 'display_name' => 'openclassify',
'email' => "info@openclassify.com", 'email' => "info@openclassify.com",
'username' => "openclassify", 'username' => "openclassify",
'password' => "openclassify", 'password' => "openclassify",
] ]
); );
$visiosoft_administrator->roles()->sync([$admin->getId()]); $visiosoft_administrator->roles()->sync([$admin->getId()]);
$this->activator->force($visiosoft_administrator); $this->activator->force($visiosoft_administrator);
//Footer Link //Footer Link
LinkModel::query()->forceDelete(); LinkModel::query()->forceDelete();
$repository = new EntryRepository(); $repository = new EntryRepository();
$repository->setModel(new UrlLinkTypeModel()); $repository->setModel(new UrlLinkTypeModel());
$menu = $this->menus->findBySlug('footer'); $menu = $this->menus->findBySlug('footer');
$openclassify = $repository->create( $openclassify = $repository->create(
[ [
'en' => [ 'en' => [
'title' => 'OpenClassify.com', 'title' => 'OpenClassify.com',
], ],
'url' => 'https://openclassify.com/', 'url' => 'https://openclassify.com/',
] ]
); );
$visiosoft = $repository->create( $visiosoft = $repository->create(
[ [
'en' => [ 'en' => [
'title' => 'Visiosoft Inc.', 'title' => 'Visiosoft Inc.',
], ],
'url' => 'https://visiosoft.com.tr/', 'url' => 'https://visiosoft.com.tr/',
] ]
); );
LinkModel::query()->create( LinkModel::query()->create(
[ [
'menu' => $menu, 'menu' => $menu,
'target' => '_blank', 'target' => '_blank',
'entry' => $openclassify, 'entry' => $openclassify,
'type' => 'anomaly.extension.url_link_type', 'type' => 'anomaly.extension.url_link_type',
] ]
); );
LinkModel::query()->create( LinkModel::query()->create(
[ [
'menu' => $menu, 'menu' => $menu,
'target' => '_blank', 'target' => '_blank',
'entry' => $visiosoft, 'entry' => $visiosoft,
'type' => 'anomaly.extension.url_link_type', 'type' => 'anomaly.extension.url_link_type',
] ]
); );
$repository = "https://raw.githubusercontent.com/openclassify/Openclassify-Demo-Data/upgrade3.8/"; $repository = "https://raw.githubusercontent.com/openclassify/Openclassify-Demo-Data/master/";
file_put_contents(storage_path('advs.sql'), fopen($repository . "advs.sql", 'r')); file_put_contents(storage_path('advs.sql'), fopen($repository . "advs.sql", 'r'));
file_put_contents(storage_path('settings.sql'), fopen($repository . "settings.sql", 'r')); file_put_contents(storage_path('settings.sql'), fopen($repository . "settings.sql", 'r'));
file_put_contents(storage_path('categories.sql'), fopen($repository . "categories.sql", 'r')); file_put_contents(storage_path('categories.sql'), fopen($repository . "categories.sql", 'r'));
file_put_contents(storage_path('images.zip'), fopen($repository . "images.zip", "r")); file_put_contents(storage_path('images.zip'), fopen($repository . "images.zip", "r"));
file_put_contents(storage_path('cats.zip'), fopen($repository . "cats.zip", "r")); file_put_contents(storage_path('cats.zip'), fopen($repository . "cats.zip", "r"));
Model::unguard(); Model::unguard();
DB::unprepared(file_get_contents(storage_path('advs.sql'))); DB::unprepared(file_get_contents(storage_path('advs.sql')));
DB::unprepared(file_get_contents(storage_path('categories.sql'))); DB::unprepared(file_get_contents(storage_path('categories.sql')));
DB::unprepared(file_get_contents(storage_path('settings.sql'))); DB::unprepared(file_get_contents(storage_path('settings.sql')));
Model::reguard(); Model::reguard();
$zip = new \ZipArchive(); $zip = new \ZipArchive();
$zip->open(storage_path('images.zip'), ZipArchive::CREATE); $zip->open(storage_path('images.zip'), ZipArchive::CREATE);
$zip->extractTo(storage_path('streams/default/files-module/local/images/')); $zip->extractTo(storage_path('streams/default/files-module/local/images/'));
$zip->open(storage_path('cats.zip'), ZipArchive::CREATE); $zip->open(storage_path('cats.zip'), ZipArchive::CREATE);
$zip->extractTo(storage_path('streams/default/files-module/local/images/')); $zip->extractTo(storage_path('streams/default/files-module/local/category_icon/'));
$zip->close(); $zip->close();
$this->call(widgetSeeder::class); //Sync Files
$this->command->call('files:sync');
$this->call(widgetSeeder::class);
//Create Store Icon Folder //Create Store Icon Folder
if (!$this->folders->findBySlug('ads_excel')) { if (!$this->folders->findBySlug('ads_excel')) {
$disk = $this->disks->findBySlug('local'); $disk = $this->disks->findBySlug('local');
$this->folders->create([ $this->folders->create([
'en' => [ 'en' => [
'name' => 'Ads Excel', 'name' => 'Ads Excel',
'description' => 'A folder for Ads Excel.', 'description' => 'A folder for Ads Excel.',
], ],
'slug' => 'ads_excel', 'slug' => 'ads_excel',
'disk' => $disk 'disk' => $disk
]); ]);
}; };
if ($images_folder = $this->folders->findBySlug('images')) { if ($images_folder = $this->folders->findBySlug('images')) {
$images_folder->update([ $images_folder->update([
'allowed_types' => [ 'allowed_types' => [
'jpg', 'jpeg','png' 'jpg', 'jpeg', 'png'
], ],
]); ]);
} }
//Favicon Folder //Favicon Folder
@ -165,35 +172,35 @@ class DatabaseSeeder extends Seeder
$disk = $this->disks->findBySlug('local'); $disk = $this->disks->findBySlug('local');
$this->folders->create([ $this->folders->create([
'en' => [ 'en' => [
'name' => 'Favicon', 'name' => 'Favicon',
'description' => 'A folder for Favicon.', 'description' => 'A folder for Favicon.',
], ],
'slug' => 'favicon', 'slug' => 'favicon',
'disk' => $disk, 'disk' => $disk,
'allowed_types' => [ 'allowed_types' => [
'ico','png', 'ico', 'png',
], ],
]); ]);
}; };
//Create Ads Documents Folder //Create Ads Documents Folder
if (!$this->folders->findBySlug('ads_documents')) { if (!$this->folders->findBySlug('ads_documents')) {
$disk = $this->disks->findBySlug('local'); $disk = $this->disks->findBySlug('local');
$this->folders->create([ $this->folders->create([
'en' => [ 'en' => [
'name' => 'Ads Documents', 'name' => 'Ads Documents',
'description' => 'A folder for Ads Documents.', 'description' => 'A folder for Ads Documents.',
], ],
'slug' => 'ads_documents', 'slug' => 'ads_documents',
'disk' => $disk, 'disk' => $disk,
'allowed_types' => [ 'allowed_types' => [
'pdf', 'doc', 'docx', 'xls', 'xlsx', 'pdf', 'doc', 'docx', 'xls', 'xlsx',
], ],
]); ]);
}; };
//Create Category Icon Folder //Create Category Icon Folder