battle with structure

This commit is contained in:
2024-10-22 13:30:03 +05:00
parent 5ffb0f2926
commit 96a5430cac
30 changed files with 1038 additions and 6 deletions

Binary file not shown.

View File

@@ -0,0 +1,49 @@
<?php
namespace $NAMESPACE$;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class $CONTROLLER_NAME$ extends Controller
{
/**
* Display a listing of the resource.
*/
public function index(Request $request): void
{
//
}
/**
* Store a newly created resource in storage.
*/
public function store(Request $request): void
{
//
}
/**
* Display the specified resource.
*/
public function show(Request $request): void
{
//
}
/**
* Update the specified resource in storage.
*/
public function update(Request $request): void
{
//
}
/**
* Remove the specified resource from storage.
*/
public function destroy(Request $request): void
{
//
}
}

View File

@@ -0,0 +1,62 @@
<?php
namespace $NAMESPACE$;
use App\Modules\$MODEL_NAME_SINGULAR$\Filament\Resources\$MODEL_NAME_SINGULAR$Resource\Pages\Create$MODEL_NAME_SINGULAR$;
use App\Modules\$MODEL_NAME_SINGULAR$\Filament\Resources\$MODEL_NAME_SINGULAR$Resource\Pages\Edit$MODEL_NAME_SINGULAR$;
use App\Modules\$MODEL_NAME_SINGULAR$\Filament\Resources\$MODEL_NAME_SINGULAR$Resource\Pages\List$MODEL_NAME_SINGULAR$s;
use $MODEL_NAMESPACE$;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Table;
class $MODEL_NAME_SINGULAR$Resource extends Resource
{
protected static ?string $model = $MODEL_NAME_SINGULAR$::class;
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
public static function form(Form $form): Form
{
return $form
->schema([
// ...
]);
}
public static function table(Table $table): Table
{
return $table
->columns([
])
->filters([
//
])
->actions([
Tables\Actions\EditAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
]),
]);
}
public static function getRelations(): array
{
return [
//
];
}
public static function getPages(): array
{
return [
'index' => List$MODEL_NAME_PLURAL$::route('/'),
'create' => Create$MODEL_NAME_SINGULAR$::route('/create'),
'edit' => Edit$MODEL_NAME_SINGULAR$::route('/{record}/edit'),
];
}
}

View File

@@ -0,0 +1,11 @@
<?php
namespace $CREATE_RESOURCE_PAGE_NAMESPACE$;
use $BASE_RESOURCE_NAMESPACE$;
use Filament\Resources\Pages\CreateRecord;
class Create$MODEL_NAME_SINGULAR$ extends CreateRecord
{
protected static string $resource = $MODEL_NAME_SINGULAR$Resource::class;
}

View File

@@ -0,0 +1,19 @@
<?php
namespace $EDIT_RESOURCE_PAGE_NAMESPACE$;
use $BASE_RESOURCE_NAMESPACE$;
use Filament\Actions;
use Filament\Resources\Pages\EditRecord;
class Edit$MODEL_NAME_SINGULAR$ extends EditRecord
{
protected static string $resource = $MODEL_NAME_SINGULAR$Resource::class;
protected function getHeaderActions(): array
{
return [
Actions\DeleteAction::make(),
];
}
}

View File

@@ -0,0 +1,19 @@
<?php
namespace $LIST_RESOURCE_PAGE_NAMESPACE$;
use $BASE_RESOURCE_NAMESPACE$;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;
class List$MODEL_NAME_PLURAL$ extends ListRecords
{
protected static string $resource = $MODEL_NAME_SINGULAR$Resource::class;
protected function getHeaderActions(): array
{
return [
Actions\CreateAction::make(),
];
}
}

View File

@@ -0,0 +1,27 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('{{ table }}', function (Blueprint $table) {
$table->id();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('{{ table }}');
}
};

View File

@@ -0,0 +1,11 @@
<?php
namespace $NAMESPACE$;
use Illuminate\Database\Eloquent\Concerns\HasUuids;
use Illuminate\Database\Eloquent\Model;
class $CLASS_NAME$ extends Model
{
}

View File

@@ -0,0 +1,48 @@
<?php
namespace $NAMESPACE$;
use App\Modules\Makeable;
use App\Modules\ModuleContract;
class $CLASS_NAME$ implements ModuleContract
{
use Makeable;
/**
* Module is enabled
*/
protected bool $enabled = true;
/**
* Check if is module enabled
*/
public function isEnabled(): bool
{
return $this->enabled;
}
/**
* Disable module
*/
public function disable(): void
{
$this->enabled = false;
}
/**
* Enable module
*/
public function enable(): void
{
$this->enabled = true;
}
/**
* Check if module has a filament resource
*/
public function hasFilamentResource(): bool
{
return true;
}
}

View File

@@ -0,0 +1,74 @@
<?php
namespace $NAMESPACE$;
use App\Nova\Resource;
use Laravel\Nova\Fields\ID;
use Laravel\Nova\Http\Requests\NovaRequest;
/**
* @template TModel of \$MODEL_NAMESPACE$
*
* @extends Resource<TModel>
*/
class $RESOURCE_NAME_SINGULAR$ extends Resource
{
/**
* The model the resource corresponds to.
*
* @var class-string<\$MODEL_NAMESPACE$>
*/
public static $model = \$MODEL_NAMESPACE$::class;
/**
* The single value that should be used to represent the resource when being displayed.
*
* @var string
*/
public static $title = 'id';
/**
* The columns that should be searched.
*
* @var array<int, string>
*/
public static $search = [
'id',
];
/**
* The relationships that should be eager loaded on index queries.
*
* @var array<int, string>
*/
// public static $with = [];
/**
* Get the displayable label of the resource.
*/
public static function label(): string
{
return __('$MODEL_NAME_PLURAL$');
}
/**
* Get the displayable singular label of the resource.
*/
public static function singularLabel(): string
{
return __('$MODEL_NAME_SINGULAR$');
}
/**
* Get the fields displayed by the resource.
*
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
* @return array<int, \Laravel\Nova\Fields\FieldElement|\Laravel\Nova\Panel>
*/
public function fields(NovaRequest $request): array
{
return [
ID::make('id')->sortable(),
];
}
}

View File

@@ -0,0 +1,10 @@
<?php
namespace $NAMESPACE$;
use $MODEL_NAMESPACE$;
class $MODULE_NAME$Repository
{
}