1. Go to this page and download the library: Download weblebby/framework 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/ */
weblebby / framework example snippets
use App\Http\Middleware\AdminPanel;
use Weblebby\Framework\Facades\Panel;
use Weblebby\Framework\Support\Features;
/**
* Create a new panel named "admin".
*/
Panel::create('admin')
->prefix('admin')
->as('admin::')
->middleware(AdminPanel::class) // We will create this middleware later.
->features([
/**
* You can delete the features you want.
*/
Features::users(),
Features::roles(),
Features::registration(),
Features::preferences(),
Features::navigations(),
Features::extensions(),
Features::themes(),
Features::appearance(),
Features::setup(),
]);
/**
* Set as main panel.
*/
Panel::setMainPanel('admin');
// app/Models/User.php
// remove
- use Illuminate\Foundation\Auth\User as Authenticatable;
// add
+ use Weblebby\Framework\Models\User as Authenticatable;
public function authorizedPanels(): array|bool
{
if ($this->hasRole('Super Admin')) {
// Grant access to all panels.
return true;
}
if ($this->hasRole('Reseller')) {
// Grant access to specific panels.
return ['reseller'];
}
// Deny all access.
return false;
}
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;
use Weblebby\Framework\Facades\Panel;
use Weblebby\Framework\Items\MenuItem;
use Weblebby\Framework\Support\Features;
class AdminPanel
{
/**
* Handle an incoming request.
*
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
*/
public function handle(Request $request, Closure $next): Response
{
/**
* We must set "admin" panel as current.
*/
Panel::setCurrentPanel('admin');
/**
* Initialize menu for "admin" panel.
*/
panel()->menu('sidebar')
->withCategory('general')
->addMany([
MenuItem::create(__('Users'))
->withUrl(route('admin::users.index'))
->withActive($request->routeIs('admin::users.*'))
->withIcon('people')
->withAbility([panel()->supports(Features::users()), 'user:read']),
MenuItem::create(__('Preferences'))
->withUrl(route('admin::preferences.index'))
->withActive($request->routeIs('admin::preferences.*'))
->withIcon('sliders')
->withAbility([
panel()->supports(Features::preferences()),
fn () => auth()->user()->getAllPermissions()
->pluck('name')
->intersect(panel()->preference('default')->toPermissions())
->isNotEmpty(),
]),
]);
/**
* You can create menu items for custom categories.
*/
panel()->menu('sidebar')
->withCategory('content', __('Content'))
->addMany([
MenuItem::create(__('Cars'))
->withUrl(route('admin::preferences.index'))
->withActive($request->routeIs('admin::cars.*'))
->withIcon('people')
->withAbility('car:read'),
]);
/**
* Set preference sections for "admin" panel.
*
* We will set the fields of these bags within a service provider later.
*/
panel()
->preference('default')
->withBag('general', __('General settings'))
->withBag('email', __('Email settings'));
/**
* Set default permissions for "Role Permissions" page.
*/
panel()->permission()->defaults(
navigations: true,
users: true,
extensions: true,
appearance: true,
preferences: true,
roles: true,
);
/**
* You can create custom permissions.
*/
panel()->permission()
->withGroup('car')
->withTitle(__('Cars'))
->withPermissions([
'create' => __('Can create cars'),
'read' => __('Can view cars'),
'update' => __('Can edit cars'),
'delete' => __('Can delete cars'),
]);
return $next($request);
}
}
use Weblebby\Framework\Facades\Panel;
$this->routes(function () {
Panel::useRoutes();
Panel::useFortifyRoutes();
// ...
});
namespace App\Providers;
use Weblebby\Framework\Facades\Preference;
use Weblebby\Framework\Items\Field\FieldItem;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*/
public function register(): void
{
// ...
}
/**
* Bootstrap any application services.
*/
public function boot(): void
{
Preference::create('default', 'general')->addMany([
FieldItem::text('site_name')
->label(__('Site name'))
->hint(__('Enter your site name.'))
->rules(['mage('site_logo')
->label(__('Site Logo'))
->rules(['nullable', 'image', 'max:2048']),
]);
}
}
shell
php artisan make:middleware AdminPanel
shell
php artisan weblebby:install
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.