1. Go to this page and download the library: Download sierratecnologia/siravel 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/ */
sierratecnologia / siravel example snippets
return [
// Negócio/organização padrão
'default' => env('SIRAVEL_DEFAULT_BUSINESS', 'ricasolucoes'),
// Prefixo de tabelas do banco de dados
'db-prefix' => env('SIRAVEL_DB_PREFIX', ''),
// Paginação padrão
'pagination' => env('SIRAVEL_PAGINATION', 25),
// Tema frontend padrão
'frontend-theme' => env('SIRAVEL_THEME', 'default'),
// Habilitar multi-tenancy
'multi-tenant' => env('SIRAVEL_MULTI_TENANT', true),
// Configurações de features
'features' => [
'blog' => true,
'commerce' => true,
'travels' => false,
// ... outras features
],
];
use Siravel\Services\BusinessService;
// Obter o negócio atual baseado no domínio
$business = app(BusinessService::class)->getCurrentBusiness();
// Alternar contexto de tenant
Business::set($business);
// Verificar features ativas para o tenant
if (Features::isActive('commerce')) {
// Lógica de e-commerce
}
use Siravel\Facades\Features;
// Verificar se uma feature está ativa
if (Features::isActive('blog')) {
// Código do blog
}
// Ativar feature para um negócio
$business->features()->attach('commerce');
// Desativar feature
$business->features()->detach('travels');
namespace Tests\Feature;
use Tests\TestCase;
use Siravel\Models\Blog\Post;
class BlogTest extends TestCase
{
public function test_can_create_post()
{
$post = Post::create([
'title' => 'Test Post',
'content' => 'Test Content',
]);
$this->assertDatabaseHas('posts', [
'title' => 'Test Post',
]);
}
}
namespace App\Services;
use Siravel\Services\BaseService;
class CustomService extends BaseService
{
public function processData($data)
{
// Lógica de negócio
}
}
namespace App\Repositories;
use Siravel\Repositories\SiravelRepository;
class CustomRepository extends SiravelRepository
{
protected $model = CustomModel::class;
public function findByCustomCriteria($criteria)
{
return $this->model->where('field', $criteria)->get();
}
}
// Event
namespace Siravel\Events;
class BusinessNewRegister
{
public $business;
public function __construct($business)
{
$this->business = $business;
}
}
// Listener
Event::listen(BusinessNewRegister::class, function($event) {
// Processar novo negócio
});