1. Go to this page and download the library: Download moox/core 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/ */
moox / core example snippets
use Moox\Core\Traits\Base\BaseInResource;
use Moox\Core\Traits\SoftDelete\SingleSoftDeleteInResource;
class YourResource extends Resource
{
use BaseInResource;
use SingleSoftDeleteInResource;
}
use Moox\Core\Traits\Tabs\TabsInListPage;
class ListItems extends ListRecords
{
use TabsInListPage;
public function getTabs(): array
{
return $this->getDynamicTabs('package.resources.item.tabs', YourModel::class);
}
}
'resources' => [
'item' => [
/*
|--------------------------------------------------------------------------
| Tabs
|--------------------------------------------------------------------------
|
| Define the tabs for the Resource table. They are optional, but
| pretty awesome to filter the table by certain values.
| You may simply do a 'tabs' => [], to disable them.
|
*/
'tabs' => [
'all' => [
'label' => 'trans//core::core.all',
'icon' => 'gmdi-filter-list',
'query' => [],
],
'documents' => [
'label' => 'trans//core::core.documents',
'icon' => 'gmdi-text-snippet',
'query' => [
[
'field' => 'expiry_job',
'operator' => '=',
'value' => 'Documents',
],
],
],
],
],
],
use Moox\Core\Traits\TranslatableConfig;
class YourServiceProvider extends ServiceProvider
{
use TranslatableConfig;
public function boot()
{
$this->translateConfigurations();
}
}
'label' => 'trans//core::core.all',
use Moox\Core\Traits\RequestInModel;
class YourModel extends Model
{
use RequestInModel;
public function someMethod()
{
$data = $this->getRequestData('some_key');
}
}
use Illuminate\Database\Eloquent\Model;
use Moox\Core\Traits\RequestInModel;
class WpTerm extends Model
{
use RequestInModel;
$description = $wpTerm->getRequestData('description');
}
use Moox\Core\Traits\GoogleIcons;
class YourServiceProvider extends ServiceProvider
{
use GoogleIcons;
public function boot()
{
$this->useGoogleIcons();
}
}
use Moox\Core\Traits\Taxonomy\TaxonomyInModel;
class YourItem extends Model
{
use TaxonomyInModel;
protected function getResourceName(): string
{
return 'youritem'; // name your item
}
// ... other model code ...
// Add a polymorphic relation
public function youritemables(string $type): MorphToMany
{
return $this->morphedByMany($type, 'youritemable');
}
// Delete relations on (soft)-delete
public function detachAllYouritemables(): void
{
DB::table('youritemables')->where('youritem_id', $this->id)->delete();
}
// Needed for deletion
protected static function booted(): void
{
static::deleting(function (YourItem $youritem) {
$youritem->detachAllYouritemables();
});
}
}
use Moox\Core\Traits\Taxonomy\TaxonomyInResource;
class YourResource extends Resource
{
use TaxonomyInResource;
public static function form(Form $form): Form
{
return $form->schema([
// ... other fields ...
...static::getTaxonomyFields(),
]);
}
public static function table(Table $table): Table
{
return $table
->columns([
// ... other columns ...
...static::getTaxonomyColumns(),
])
->filters([
// ... other filters ...
...static::getTaxonomyFilters(),
]);
}
}
use Moox\Core\Traits\Taxonomy\TaxonomyInPages;
class EditYourModel extends EditRecord
{
use TaxonomyInPages;
// ... other page code ...
}
$this->logDebug('This is a debug message');
$this->logInfo('This is an info message');
use Moox\Core\Services\TaxonomyService;
class YourClass
{
protected TaxonomyService $taxonomyService;
public function __construct(TaxonomyService $taxonomyService)
{
$this->taxonomyService = $taxonomyService;
$this->taxonomyService->setCurrentResource('your_resource');
}
public function someMethod()
{
$taxonomies = $this->taxonomyService->getTaxonomies();
// ... use taxonomies ...
}
}
use Moox\Core\Services\DnsLookupService;
class YourClass
{
public function someMethod(string $domain)
{
$ipAddress = DnsLookupService::getIpAddress($domain);
}
}
use Moox\Core\Services\DnsLookupService;
class PlatformResource extends Resource
{
public static function form(Form $form): Form
{
return $form->schema([
Section::make()->schema([
Grid::make(['default' => 0])->schema([
TextInput::make('domain')
->label(__('core::core.domain'))
->rules(['max:255', 'string'])
-> $set('ip_address', $ipAddress ?: 'The host is not resolvable');
}
})
]),
]),
]);
use Moox\Tag\Forms\TaxonomyCreateForm;
class YourResource extends Resource
{
public static function form(Form $form): Form
{
return $form->schema([
// ... other fields ...
...TaxonomyCreateForm::getSchema(),
]);
}
}
/*
|--------------------------------------------------------------------------
| Moox Packages
|--------------------------------------------------------------------------
|
| This config array registers all known Moox packages. You may add own
| packages to this array. If you use Moox Builder, these packages
| work out of the box. Adding a non-compatible package fails.
|
*/
'packages' => [
'audit' => 'Moox Audit',
'builder' => 'Moox Builder',
'core' => 'Moox Core',
'expiry' => 'Moox Expiry',
'jobs' => 'Moox Jobs',
'login-link' => 'Moox Login Link',
'notifications' => 'Moox Notifications',
'page' => 'Moox Page',
'passkey' => 'Moox Passkey',
'permission' => 'Moox Permission',
'press' => 'Moox Press',
'press-wiki' => 'Moox Press Wiki',
'security' => 'Moox Security',
'sync' => 'Moox Sync',
'training' => 'Moox Trainings',
'user' => 'Moox User',
'user-device' => 'Moox User Device',
'user-session' => 'Moox User Session',
],
];
/*
|--------------------------------------------------------------------------
| Google Icons
|--------------------------------------------------------------------------
|
| We use Google Material Design Icons, but if you want to use the
| Heroicons, used by Filament as default, you can disable the
| Google Icons here. This will affect the whole application.
|
*/
'google_icons' => true,
/*
|--------------------------------------------------------------------------
| Logging
|--------------------------------------------------------------------------
|
| This config array sets the logging level and whether to log in
| production. It is used by some Moox packages where verbose
| logging is a good thing while implementing complex stuff.
|
*/
'logging' => [
'verbose_level' => env('VERBOSE_LEVEL', 0), // 0: Off, 1: Debug, 2: Info, 3: All
'log_in_production' => env('LOG_IN_PRODUCTION', false),
],
/*
|--------------------------------------------------------------------------
| Shared Hosting
|--------------------------------------------------------------------------
|
| This config array sets the shared hosting token. This token is used to
| authenticate requests from shared hosting environments.
|
*/
'shared_hosting' => [
'enabled' => env('SHARED_HOSTING_ENABLED', false),
'token' => env('SHARED_HOSTING_TOKEN', 'secret'),
],
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.