initial import

This commit is contained in:
2025-07-30 09:47:03 +02:00
commit b0a186a324
292 changed files with 32323 additions and 0 deletions

View File

@@ -0,0 +1,74 @@
<?php
namespace App\Filament\Resources\PluginResource;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Pagination\Paginator;
class CollectionEloquentBuilder extends Builder
{
protected $collection;
public function __construct($query)
{
parent::__construct($query);
$this->collection = new Collection(); // Initialize with an empty collection
}
public function setCollection(Collection $collection)
{
$this->collection = $collection;
return $this;
}
public function get($columns = ['*'])
{
return $this->collection;
}
public function find($id, $columns = ['*'])
{
return $this->collection->firstWhere('id', $id);
}
public function paginate($perPage = null, $columns = ['*'], $pageName = 'page', $page = null)
{
$page = $page ?: Paginator::resolveCurrentPage($pageName);
$results = $this->collection->slice(($page - 1) * $perPage, $perPage)->all();
return new LengthAwarePaginator($results, $this->collection->count(), $perPage, $page, [
'path' => Paginator::resolveCurrentPath(),
'pageName' => $pageName,
]);
}
public function count($columns = '*')
{
return $this->collection->count();
}
public function where($column, $operator = null, $value = null, $boolean = 'and')
{
if (func_num_args() === 2) {
[$value, $operator] = [$operator, '='];
}
if ($operator === '=') {
$this->collection = $this->collection->where($column, $value);
} else {
// For simplicity, only handling '=' operator for now. More complex operators would require more logic.
// For example, for 'like', you'd need to implement string matching.
}
return $this;
}
public function orderBy($column, $direction = 'asc')
{
$this->collection = $this->collection->sortBy($column, SORT_REGULAR, $direction === 'desc');
return $this;
}
}

View File

@@ -0,0 +1,36 @@
<?php
namespace App\Filament\Resources\PluginResource;
use Illuminate\Database\Eloquent\Model;
class Plugin extends Model
{
protected $table = null; // No actual table
protected $guarded = []; // Allow mass assignment for all attributes
public $incrementing = false;
protected $keyType = 'string';
protected $primaryKey = 'id';
public function __construct(array $attributes = [])
{
parent::__construct($attributes);
foreach ($attributes as $key => $value) {
$this->$key = $value;
}
}
public function newCollection(array $models = [])
{
return new \Illuminate\Database\Eloquent\Collection($models);
}
public function newEloquentBuilder($query)
{
return new CollectionEloquentBuilder($query);
}
}