1. Go to this page and download the library: Download damianulan/laravel-lucent 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/ */
damianulan / laravel-lucent example snippets
namespace App\Services;
use App\Models\Campaign;
use Lucent\Services\Service;
class CreateOrUpdateCampaign extends Service
{
protected function authorize(): bool
{
return $this->request()->user()?->can('campaigns.manage') ?? false;
}
protected function rules(): array
{
return [
'name' => [';
}
}
use App\Forms\BaseForm;
use Lucent\Support\Magellan\MagellanScope;
$forms = MagellanScope::blacklist([
'App\\Console\\',
'App\\Providers\\',
])
->filter(fn (\ReflectionClass $class) => $class->isSubclassOf(BaseForm::class))
->get();
namespace App\Support\Magellan;
use Lucent\Support\Magellan\MagellanScope;
use Lucent\Support\Magellan\Workshop\ScopeUsesCache;
class PolicyScope extends MagellanScope implements ScopeUsesCache
{
protected function scope(\ReflectionClass $class): bool
{
return str_ends_with($class->getName(), 'Policy');
}
public function ttl(): int
{
return 3600;
}
}
$policies = PolicyScope::get();
use App\Models\Scopes\UserScope;
use Illuminate\Database\Eloquent\Model;
use Lucent\Support\Traits\Accessible;
class User extends Model
{
use Accessible;
protected string $accessScope = UserScope::class;
}
public static function getUuidKeyName(): string
{
return 'public_id';
}
use Illuminate\Database\Eloquent\Model;
use Lucent\Support\Traits\VirginModel;
class Post extends Model
{
use VirginModel;
protected $fillable = [
'title',
'active',
'draft',
];
}
use Illuminate\Database\Eloquent\Model;
use Lucent\Support\Traits\CascadeDeletes;
class User extends Model
{
use CascadeDeletes;
protected array $cascadeDelete = ['profile', 'posts'];
}
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Lucent\Support\Traits\SoftDeletesPrunable;
class Archive extends Model
{
use SoftDeletes;
use SoftDeletesPrunable;
}