mirror of
https://github.com/openclassify/openclassify.git
synced 2026-01-11 18:01:10 -06:00
commit
b53a852a6a
@ -64,4 +64,9 @@ class CategoryModel extends CatsCategoryEntryModel implements CategoryInterface
|
||||
{
|
||||
$this->update(['icon' => $url]);
|
||||
}
|
||||
|
||||
public function getSubCategories()
|
||||
{
|
||||
return $this->where('parent_category_id', $this->getId())->get();
|
||||
}
|
||||
}
|
||||
|
||||
@ -146,13 +146,13 @@ class CategoryRepository extends EntryRepository implements CategoryRepositoryIn
|
||||
'c1.id',
|
||||
'c1.slug',
|
||||
'c1.parent_category_id',
|
||||
'c1.icon_id',
|
||||
'c1.icon',
|
||||
't1.name',
|
||||
'c2.id as c2_id',
|
||||
'c2.slug as c2_slug',
|
||||
'c2.icon as c2_icon',
|
||||
'c2.parent_category_id as c2_parent_category_id',
|
||||
't2.name as c2_name',
|
||||
'file.id as file_id'
|
||||
't2.name as c2_name'
|
||||
)
|
||||
->leftJoin($dBName . ' as c2', function ($join) {
|
||||
$join->on('c2.parent_category_id', '=', 'c1.id')
|
||||
@ -166,7 +166,6 @@ class CategoryRepository extends EntryRepository implements CategoryRepositoryIn
|
||||
$join->on('c2.id', '=', 't2.entry_id')
|
||||
->where('t2.locale', Request()->session()->get('_locale', setting_value('streams::default_locale')));
|
||||
})
|
||||
->leftJoin('files_files as file', 'c1.icon_id', 'file.id')
|
||||
->whereNull('c1.deleted_at')
|
||||
->whereNull('c1.parent_category_id')
|
||||
->orderBy('c1.sort_order')
|
||||
|
||||
@ -13,4 +13,6 @@ interface CategoryInterface extends EntryInterface
|
||||
public function getMains($id);
|
||||
|
||||
public function setCategoryIconUrl($url);
|
||||
|
||||
public function getSubCategories();
|
||||
}
|
||||
|
||||
@ -6,158 +6,165 @@ use Anomaly\FilesModule\Folder\Contract\FolderRepositoryInterface;
|
||||
use Anomaly\NavigationModule\Link\LinkModel;
|
||||
use Anomaly\NavigationModule\Menu\Contract\MenuRepositoryInterface;
|
||||
use Anomaly\Streams\Platform\Entry\EntryRepository;
|
||||
use Anomaly\Streams\Platform\Model\Users\UsersUsersEntryModel;
|
||||
use Anomaly\UrlLinkTypeExtension\UrlLinkTypeModel;
|
||||
use Anomaly\UsersModule\Role\Contract\RoleRepositoryInterface;
|
||||
use Anomaly\UsersModule\User\Contract\UserInterface;
|
||||
use Anomaly\UsersModule\User\Contract\UserRepositoryInterface;
|
||||
use Anomaly\UsersModule\User\UserActivator;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Anomaly\DashboardModule\Widget\Contract\WidgetRepositoryInterface;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use WidgetSeeder;
|
||||
use ZipArchive;
|
||||
|
||||
class DatabaseSeeder extends Seeder
|
||||
{
|
||||
protected $widgets;
|
||||
protected $menus;
|
||||
protected $users;
|
||||
protected $roles;
|
||||
protected $activator;
|
||||
protected $disks;
|
||||
protected $folders;
|
||||
protected $widgets;
|
||||
protected $menus;
|
||||
protected $users;
|
||||
protected $roles;
|
||||
protected $activator;
|
||||
protected $disks;
|
||||
protected $folders;
|
||||
protected $command;
|
||||
|
||||
public function __construct(
|
||||
WidgetRepositoryInterface $widgets,
|
||||
MenuRepositoryInterface $menus,
|
||||
UserRepositoryInterface $users,
|
||||
DiskRepositoryInterface $disks,
|
||||
FolderRepositoryInterface $folders,
|
||||
RoleRepositoryInterface $roles,
|
||||
UserActivator $activator
|
||||
)
|
||||
{
|
||||
$this->widgets = $widgets;
|
||||
$this->menus = $menus;
|
||||
$this->users = $users;
|
||||
$this->roles = $roles;
|
||||
$this->activator = $activator;
|
||||
$this->disks = $disks;
|
||||
$this->folders = $folders;
|
||||
}
|
||||
public function __construct(
|
||||
WidgetRepositoryInterface $widgets,
|
||||
MenuRepositoryInterface $menus,
|
||||
UserRepositoryInterface $users,
|
||||
DiskRepositoryInterface $disks,
|
||||
FolderRepositoryInterface $folders,
|
||||
RoleRepositoryInterface $roles,
|
||||
UserActivator $activator,
|
||||
Command $command
|
||||
)
|
||||
{
|
||||
$this->widgets = $widgets;
|
||||
$this->menus = $menus;
|
||||
$this->users = $users;
|
||||
$this->roles = $roles;
|
||||
$this->activator = $activator;
|
||||
$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->newQuery()->where('email', "info@openclassify.com")->forceDelete();
|
||||
$visiosoft_administrator = $this->users->create(
|
||||
[
|
||||
'first_name' => 'Dev',
|
||||
'last_name' => 'Openclassify',
|
||||
'display_name' => 'openclassify',
|
||||
'email' => "info@openclassify.com",
|
||||
'username' => "openclassify",
|
||||
'password' => "openclassify",
|
||||
]
|
||||
);
|
||||
$this->users->unguard();
|
||||
$this->users->newQuery()->where('email', "info@openclassify.com")->forceDelete();
|
||||
$visiosoft_administrator = $this->users->create(
|
||||
[
|
||||
'first_name' => 'Dev',
|
||||
'last_name' => 'Openclassify',
|
||||
'display_name' => 'openclassify',
|
||||
'email' => "info@openclassify.com",
|
||||
'username' => "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
|
||||
LinkModel::query()->forceDelete();
|
||||
$repository = new EntryRepository();
|
||||
$repository->setModel(new UrlLinkTypeModel());
|
||||
$menu = $this->menus->findBySlug('footer');
|
||||
//Footer Link
|
||||
LinkModel::query()->forceDelete();
|
||||
$repository = new EntryRepository();
|
||||
$repository->setModel(new UrlLinkTypeModel());
|
||||
$menu = $this->menus->findBySlug('footer');
|
||||
|
||||
|
||||
$openclassify = $repository->create(
|
||||
[
|
||||
'en' => [
|
||||
'title' => 'OpenClassify.com',
|
||||
],
|
||||
'url' => 'https://openclassify.com/',
|
||||
]
|
||||
);
|
||||
$visiosoft = $repository->create(
|
||||
[
|
||||
'en' => [
|
||||
'title' => 'Visiosoft Inc.',
|
||||
],
|
||||
'url' => 'https://visiosoft.com.tr/',
|
||||
]
|
||||
);
|
||||
$openclassify = $repository->create(
|
||||
[
|
||||
'en' => [
|
||||
'title' => 'OpenClassify.com',
|
||||
],
|
||||
'url' => 'https://openclassify.com/',
|
||||
]
|
||||
);
|
||||
$visiosoft = $repository->create(
|
||||
[
|
||||
'en' => [
|
||||
'title' => 'Visiosoft Inc.',
|
||||
],
|
||||
'url' => 'https://visiosoft.com.tr/',
|
||||
]
|
||||
);
|
||||
|
||||
LinkModel::query()->create(
|
||||
[
|
||||
'menu' => $menu,
|
||||
'target' => '_blank',
|
||||
'entry' => $openclassify,
|
||||
'type' => 'anomaly.extension.url_link_type',
|
||||
]
|
||||
);
|
||||
LinkModel::query()->create(
|
||||
[
|
||||
'menu' => $menu,
|
||||
'target' => '_blank',
|
||||
'entry' => $visiosoft,
|
||||
'type' => 'anomaly.extension.url_link_type',
|
||||
]
|
||||
);
|
||||
LinkModel::query()->create(
|
||||
[
|
||||
'menu' => $menu,
|
||||
'target' => '_blank',
|
||||
'entry' => $openclassify,
|
||||
'type' => 'anomaly.extension.url_link_type',
|
||||
]
|
||||
);
|
||||
LinkModel::query()->create(
|
||||
[
|
||||
'menu' => $menu,
|
||||
'target' => '_blank',
|
||||
'entry' => $visiosoft,
|
||||
'type' => 'anomaly.extension.url_link_type',
|
||||
]
|
||||
);
|
||||
|
||||
$repository = "https://raw.githubusercontent.com/openclassify/Openclassify-Demo-Data/upgrade3.8/";
|
||||
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('categories.sql'), fopen($repository . "categories.sql", '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"));
|
||||
$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('settings.sql'), fopen($repository . "settings.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('cats.zip'), fopen($repository . "cats.zip", "r"));
|
||||
|
||||
Model::unguard();
|
||||
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('settings.sql')));
|
||||
Model::reguard();
|
||||
Model::unguard();
|
||||
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('settings.sql')));
|
||||
Model::reguard();
|
||||
|
||||
|
||||
$zip = new ZipArchive();
|
||||
$zip->open(storage_path('images.zip'), ZipArchive::CREATE);
|
||||
$zip->extractTo(storage_path('streams/default/files-module/local/images/'));
|
||||
$zip->open(storage_path('cats.zip'), ZipArchive::CREATE);
|
||||
$zip->extractTo(storage_path('streams/default/files-module/local/images/'));
|
||||
$zip->close();
|
||||
$zip = new \ZipArchive();
|
||||
$zip->open(storage_path('images.zip'), ZipArchive::CREATE);
|
||||
$zip->extractTo(storage_path('streams/default/files-module/local/images/'));
|
||||
$zip->open(storage_path('cats.zip'), ZipArchive::CREATE);
|
||||
$zip->extractTo(storage_path('streams/default/files-module/local/category_icon/'));
|
||||
$zip->close();
|
||||
|
||||
$this->call(widgetSeeder::class);
|
||||
//Sync Files
|
||||
$this->command->call('files:sync');
|
||||
|
||||
$this->call(WidgetSeeder::class);
|
||||
|
||||
|
||||
//Create Store Icon Folder
|
||||
if (!$this->folders->findBySlug('ads_excel')) {
|
||||
$disk = $this->disks->findBySlug('local');
|
||||
//Create Store Icon Folder
|
||||
if (!$this->folders->findBySlug('ads_excel')) {
|
||||
$disk = $this->disks->findBySlug('local');
|
||||
|
||||
$this->folders->create([
|
||||
'en' => [
|
||||
'name' => 'Ads Excel',
|
||||
'description' => 'A folder for Ads Excel.',
|
||||
],
|
||||
'slug' => 'ads_excel',
|
||||
'disk' => $disk
|
||||
]);
|
||||
};
|
||||
$this->folders->create([
|
||||
'en' => [
|
||||
'name' => 'Ads Excel',
|
||||
'description' => 'A folder for Ads Excel.',
|
||||
],
|
||||
'slug' => 'ads_excel',
|
||||
'disk' => $disk
|
||||
]);
|
||||
};
|
||||
|
||||
if ($images_folder = $this->folders->findBySlug('images')) {
|
||||
$images_folder->update([
|
||||
'allowed_types' => [
|
||||
'jpg', 'jpeg','png'
|
||||
],
|
||||
]);
|
||||
}
|
||||
if ($images_folder = $this->folders->findBySlug('images')) {
|
||||
$images_folder->update([
|
||||
'allowed_types' => [
|
||||
'jpg', 'jpeg', 'png'
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
//Favicon Folder
|
||||
@ -165,35 +172,35 @@ class DatabaseSeeder extends Seeder
|
||||
$disk = $this->disks->findBySlug('local');
|
||||
|
||||
$this->folders->create([
|
||||
'en' => [
|
||||
'name' => 'Favicon',
|
||||
'en' => [
|
||||
'name' => 'Favicon',
|
||||
'description' => 'A folder for Favicon.',
|
||||
],
|
||||
'slug' => 'favicon',
|
||||
'disk' => $disk,
|
||||
'slug' => 'favicon',
|
||||
'disk' => $disk,
|
||||
'allowed_types' => [
|
||||
'ico','png',
|
||||
'ico', 'png',
|
||||
],
|
||||
]);
|
||||
};
|
||||
|
||||
|
||||
//Create Ads Documents Folder
|
||||
if (!$this->folders->findBySlug('ads_documents')) {
|
||||
$disk = $this->disks->findBySlug('local');
|
||||
//Create Ads Documents Folder
|
||||
if (!$this->folders->findBySlug('ads_documents')) {
|
||||
$disk = $this->disks->findBySlug('local');
|
||||
|
||||
$this->folders->create([
|
||||
'en' => [
|
||||
'name' => 'Ads Documents',
|
||||
'description' => 'A folder for Ads Documents.',
|
||||
],
|
||||
'slug' => 'ads_documents',
|
||||
'disk' => $disk,
|
||||
'allowed_types' => [
|
||||
'pdf', 'doc', 'docx', 'xls', 'xlsx',
|
||||
],
|
||||
]);
|
||||
};
|
||||
$this->folders->create([
|
||||
'en' => [
|
||||
'name' => 'Ads Documents',
|
||||
'description' => 'A folder for Ads Documents.',
|
||||
],
|
||||
'slug' => 'ads_documents',
|
||||
'disk' => $disk,
|
||||
'allowed_types' => [
|
||||
'pdf', 'doc', 'docx', 'xls', 'xlsx',
|
||||
],
|
||||
]);
|
||||
};
|
||||
|
||||
|
||||
//Create Category Icon Folder
|
||||
@ -210,6 +217,12 @@ class DatabaseSeeder extends Seeder
|
||||
]);
|
||||
};
|
||||
|
||||
//Demodata Seeder
|
||||
if(is_module_installed('visiosoft.module.demodata'))
|
||||
{
|
||||
$this->call(\Visiosoft\DemodataModule\Demodata\DemodataSeeder::class);
|
||||
}
|
||||
|
||||
Artisan::call('assets:clear');
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@ use Anomaly\DashboardModule\Dashboard\Contract\DashboardRepositoryInterface;
|
||||
use Anomaly\DashboardModule\Widget\Contract\WidgetRepositoryInterface;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class widgetSeeder extends Seeder
|
||||
class WidgetSeeder extends Seeder
|
||||
{
|
||||
protected $widgets;
|
||||
protected $dashboards;
|
||||
Loading…
Reference in New Issue
Block a user