feat: ✨ add invoice companies crud #119
This commit is contained in:
parent
889bd85493
commit
cc45c363b5
23 changed files with 1215 additions and 12 deletions
245
app/Http/Controllers/Back/InvoiceCompanyController.php
Normal file
245
app/Http/Controllers/Back/InvoiceCompanyController.php
Normal file
|
|
@ -0,0 +1,245 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Back;
|
||||
|
||||
use App\Http\Requests\Back\InvoiceCompanies\StoreInvoiceCompanyRequest;
|
||||
use App\Http\Requests\Back\InvoiceCompanies\UpdateInvoiceCompanyRequest;
|
||||
use App\Models\InvoiceCompany;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
use Uwil\LaravelBackend\Controllers\BackendController;
|
||||
use Uwil\LaravelBackend\Resources\CommonResource;
|
||||
|
||||
/**
|
||||
* Handles CRUD operations for InvoiceCompany in the backend.
|
||||
*/
|
||||
class InvoiceCompanyController extends BackendController
|
||||
{
|
||||
/**
|
||||
* Create the controller instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->authorizeResource(InvoiceCompany::class);
|
||||
$this->modelName = InvoiceCompany::modelName();
|
||||
$this->modelPage = InvoiceCompany::modelPage();
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Inertia\Response
|
||||
*/
|
||||
public function index(Request $request): \Inertia\Response
|
||||
{
|
||||
/** @var \Illuminate\Database\Eloquent\Builder<\App\Models\InvoiceCompany> $query */
|
||||
$query = InvoiceCompany::query();
|
||||
|
||||
if ($request->routeIs("back.$this->modelName.trash")) {
|
||||
$query = $query->onlyTrashed();
|
||||
}
|
||||
|
||||
/** @var string $search Search field */
|
||||
$search = $request->search;
|
||||
if ($search) {
|
||||
$this->searchQuery(
|
||||
$query,
|
||||
$search,
|
||||
null,
|
||||
// TODO: Fields here.
|
||||
);
|
||||
}
|
||||
$searchFields = \implode(', ', [
|
||||
// TODO: Translations here.
|
||||
]);
|
||||
|
||||
/** Sort columns with a query */
|
||||
$this->sortQuery($query);
|
||||
|
||||
/** Custom pagination */
|
||||
$models = $this->paginate($query);
|
||||
|
||||
return $this->inertiaRender("back/Pages/$this->modelPage/Index", [
|
||||
'models' => CommonResource::collection($models),
|
||||
'search' => $search,
|
||||
'searchFields' => $searchFields,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @param \App\Models\InvoiceCompany $invoice_company
|
||||
* @return \Inertia\Response
|
||||
*/
|
||||
public function create(InvoiceCompany $invoice_company): \Inertia\Response
|
||||
{
|
||||
return $this->inertiaRender("back/Pages/$this->modelPage/Create", [
|
||||
'data' => CommonResource::make($invoice_company),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a specific resource.
|
||||
*
|
||||
* @param \App\Models\InvoiceCompany $invoice_company
|
||||
* @return \Inertia\Response
|
||||
*/
|
||||
public function show(InvoiceCompany $invoice_company): \Inertia\Response
|
||||
{
|
||||
return $this->inertiaRender("back/Pages/$this->modelPage/Show", [
|
||||
'data' => CommonResource::make($invoice_company),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource.
|
||||
*
|
||||
* @param \App\Http\Requests\Back\InvoiceCompanies\StoreInvoiceCompanyRequest $request
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function store(StoreInvoiceCompanyRequest $request): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
return DB::transaction(function () use ($request) {
|
||||
$invoice_company = new InvoiceCompany();
|
||||
$invoice_company->inertiaFill($request->validated());
|
||||
|
||||
if ($invoice_company->saveOrFail()) {
|
||||
return redirect()->route("back.$this->modelName.edit", $invoice_company)
|
||||
->with('success', trans('uwil-backend::crud.messages.has_been_created', [
|
||||
'model' => Str::ucfirst(trans_choice("models.classes.$this->modelName", 1)),
|
||||
]));
|
||||
}
|
||||
return redirect()->back()
|
||||
->with('error', trans('uwil-backend::crud.messages.cannot_be_created', [
|
||||
'model' => Str::ucfirst(trans_choice("models.classes.$this->modelName", 1)),
|
||||
]));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\Models\InvoiceCompany $invoice_company
|
||||
* @return \Inertia\Response
|
||||
*/
|
||||
public function edit(InvoiceCompany $invoice_company): \Inertia\Response
|
||||
{
|
||||
return $this->inertiaRender("back/Pages/$this->modelPage/Edit", [
|
||||
'data' => CommonResource::make($invoice_company),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource.
|
||||
*
|
||||
* @param \App\Http\Requests\Back\InvoiceCompanies\UpdateInvoiceCompanyRequest $request
|
||||
* @param \App\Models\InvoiceCompany $invoice_company
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function update(
|
||||
UpdateInvoiceCompanyRequest $request,
|
||||
InvoiceCompany $invoice_company
|
||||
): \Illuminate\Http\RedirectResponse {
|
||||
return DB::transaction(function () use ($request, $invoice_company) {
|
||||
$invoice_company->inertiaFill($request->validated());
|
||||
|
||||
if ($invoice_company->saveOrFail()) {
|
||||
return redirect()->route("back.$this->modelName.edit", $invoice_company)
|
||||
->with('success', trans('uwil-backend::crud.messages.has_been_updated', [
|
||||
'model' => Str::ucfirst(trans_choice("models.classes.$this->modelName", 1)),
|
||||
]));
|
||||
}
|
||||
return redirect()->route("back.$this->modelName.edit", $invoice_company)
|
||||
->with('error', trans('uwil-backend::crud.messages.cannot_be_updated', [
|
||||
'model' => Str::ucfirst(trans_choice("models.classes.$this->modelName", 1)),
|
||||
]));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Duplicate the specified resource.
|
||||
*
|
||||
* @param \App\Models\InvoiceCompany $invoice_company
|
||||
* @return \Inertia\Response
|
||||
*/
|
||||
public function duplicate(InvoiceCompany $invoice_company): \Inertia\Response
|
||||
{
|
||||
return $this->create($invoice_company->replicate());
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore the specified resource.
|
||||
*
|
||||
* @param integer $invoice_company
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function restore(int $invoice_company): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
$invoice_company = InvoiceCompany::withTrashed()->findOrFail($invoice_company);
|
||||
/** @var array<string,string> */
|
||||
$previousQueries = [];
|
||||
\parse_str(\parse_url(url()->previous(), \PHP_URL_QUERY), $previousQueries);
|
||||
if ($invoice_company->restore()) {
|
||||
return redirect()->route("back.$this->modelName.trash", $previousQueries)
|
||||
->with('success', trans('uwil-backend::crud.messages.has_been_restored', [
|
||||
'model' => Str::ucfirst(trans_choice("models.classes.$this->modelName", 1)),
|
||||
]));
|
||||
}
|
||||
return redirect()->back()
|
||||
->with('error', trans('uwil-backend::crud.messages.cannot_be_restored', [
|
||||
'model' => Str::ucfirst(trans_choice("models.classes.$this->modelName", 1)),
|
||||
]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy the specified resource.
|
||||
*
|
||||
* @param \App\Models\InvoiceCompany $invoice_company
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function destroy(InvoiceCompany $invoice_company): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
/** @var array<string,string> */
|
||||
$previousQueries = [];
|
||||
\parse_str(\parse_url(url()->previous(), \PHP_URL_QUERY), $previousQueries);
|
||||
if ($invoice_company->delete()) {
|
||||
return redirect()->route("back.$this->modelName.index", $previousQueries)
|
||||
->with('success', trans('uwil-backend::crud.messages.has_been_deleted', [
|
||||
'model' => Str::ucfirst(trans_choice("models.classes.$this->modelName", 1)),
|
||||
]));
|
||||
}
|
||||
return redirect()->back()
|
||||
->with('error', trans('uwil-backend::crud.messages.cannot_be_deleted', [
|
||||
'model' => Str::ucfirst(trans_choice("models.classes.$this->modelName", 1)),
|
||||
]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy the specified resource.
|
||||
*
|
||||
* @param \App\Models\InvoiceCompany|integer $invoice_company
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function forceDestroy(InvoiceCompany|int $invoice_company): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
if (is_int($invoice_company)) {
|
||||
$invoice_company = InvoiceCompany::withTrashed()->findOrFail($invoice_company);
|
||||
}
|
||||
/** @var array<string,string> */
|
||||
$previousQueries = [];
|
||||
\parse_str(\parse_url(url()->previous(), \PHP_URL_QUERY), $previousQueries);
|
||||
if ($invoice_company->forceDelete()) {
|
||||
return redirect()->route("back.$this->modelName.trash", $previousQueries)
|
||||
->with('success', trans('uwil-backend::crud.messages.has_been_deleted', [
|
||||
'model' => Str::ucfirst(trans_choice("models.classes.$this->modelName", 1)),
|
||||
]));
|
||||
}
|
||||
return redirect()->back()
|
||||
->with('error', trans('uwil-backend::crud.messages.cannot_be_deleted', [
|
||||
'model' => Str::ucfirst(trans_choice("models.classes.$this->modelName", 1)),
|
||||
]));
|
||||
}
|
||||
}
|
||||
|
|
@ -3,6 +3,7 @@
|
|||
namespace App\Http\Middlewares;
|
||||
|
||||
use App\Enums\NoticeTypeEnum;
|
||||
use App\Models\InvoiceCompany;
|
||||
use App\Models\InvoicePackage;
|
||||
use App\Models\Notice;
|
||||
use Illuminate\Http\Request;
|
||||
|
|
@ -35,6 +36,11 @@ class HandleInertiaRequests extends Middleware
|
|||
'viewTrash' => Gate::allows('viewTrash', InvoicePackage::class),
|
||||
'create' => Gate::allows('create', InvoicePackage::class),
|
||||
],
|
||||
'invoiceCompanies' => [
|
||||
'viewAny' => Gate::allows('viewAny', InvoiceCompany::class),
|
||||
'viewTrash' => Gate::allows('viewTrash', InvoiceCompany::class),
|
||||
'create' => Gate::allows('create', InvoiceCompany::class),
|
||||
],
|
||||
],
|
||||
],
|
||||
'noticeTypeEnum' => NoticeTypeEnum::toArray(),
|
||||
|
|
|
|||
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Back\InvoiceCompanies;
|
||||
|
||||
use App\Models\InvoiceCompany;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
|
||||
/**
|
||||
* Handles authorization and validation for creating a new InvoiceCompany.
|
||||
*/
|
||||
class StoreInvoiceCompanyRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return Gate::check('create', InvoiceCompany::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'name' => 'required|string|between:3,255',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom attributes for validator errors.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function attributes(): array
|
||||
{
|
||||
return [
|
||||
'name' => trans('validation.custom.name'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Back\InvoiceCompanies;
|
||||
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
|
||||
/**
|
||||
* Handles authorization and validation for updating an existing InvoiceCompany.
|
||||
*/
|
||||
class UpdateInvoiceCompanyRequest extends StoreInvoiceCompanyRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return Gate::check('update', $this->route('invoice_company'));
|
||||
}
|
||||
}
|
||||
48
app/Models/InvoiceCompany.php
Normal file
48
app/Models/InvoiceCompany.php
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Uwil\LaravelActivityLogs\Traits\HasActivityLog;
|
||||
use Uwil\LaravelBackend\Traits\Models\HasCache;
|
||||
use Uwil\LaravelBackend\Traits\Models\HasModelNaming;
|
||||
use Uwil\LaravelBackend\Traits\Models\HasUwilImages;
|
||||
use Uwil\LaravelI18n\Traits\Models\HasTranslations;
|
||||
|
||||
/**
|
||||
* @property integer $id Id of the invoice company.
|
||||
* @property string $name Name of the invoice company.
|
||||
* @property-read \Illuminate\Support\Carbon $created_at Date the invoice company was created.
|
||||
* @property-read \Illuminate\Support\Carbon $updated_at Date the invoice company was updated.
|
||||
* @property-read \Illuminate\Support\Carbon $deleted_at Date the invoice company was deleted.
|
||||
*/
|
||||
class InvoiceCompany extends Model
|
||||
{
|
||||
use HasActivityLog;
|
||||
use HasCache;
|
||||
use HasFactory;
|
||||
use HasModelNaming;
|
||||
use HasTranslations;
|
||||
use HasUwilImages;
|
||||
use SoftDeletes;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name',
|
||||
];
|
||||
|
||||
/**
|
||||
* The translatable columns.
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
public $translatable = [
|
||||
'name',
|
||||
];
|
||||
}
|
||||
112
app/Policies/InvoiceCompanyPolicy.php
Normal file
112
app/Policies/InvoiceCompanyPolicy.php
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Uwil\LaravelBackend\Policies\Rules\UserStaticRules;
|
||||
use Uwil\LaravelBackend\Support\UserRoleRegistry;
|
||||
|
||||
/**
|
||||
* Handles authorization for InvoiceCompany model actions.
|
||||
*/
|
||||
class InvoiceCompanyPolicy
|
||||
{
|
||||
/**
|
||||
* Determine whether the user can view any models.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Model $authModel
|
||||
* @return boolean
|
||||
*/
|
||||
public function viewAny(Model $authModel): bool
|
||||
{
|
||||
return UserStaticRules::atLeastRole($authModel, UserRoleRegistry::get('developper')->value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can view trash models.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Model $authModel
|
||||
* @return boolean
|
||||
*/
|
||||
public function viewTrash(Model $authModel): bool
|
||||
{
|
||||
return UserStaticRules::atLeastRole($authModel, UserRoleRegistry::get('developper')->value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can view the model.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Model $authModel
|
||||
* @return boolean
|
||||
*/
|
||||
public function view(Model $authModel): bool
|
||||
{
|
||||
return UserStaticRules::atLeastRole($authModel, UserRoleRegistry::get('developper')->value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can create models.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Model $authModel
|
||||
* @return boolean
|
||||
*/
|
||||
public function create(Model $authModel): bool
|
||||
{
|
||||
return UserStaticRules::atLeastRole($authModel, UserRoleRegistry::get('developper')->value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can update the model.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Model $authModel
|
||||
* @return boolean
|
||||
*/
|
||||
public function update(Model $authModel): bool
|
||||
{
|
||||
return UserStaticRules::atLeastRole($authModel, UserRoleRegistry::get('developper')->value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can duplicate the model.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Model $authModel
|
||||
* @return boolean
|
||||
*/
|
||||
public function duplicate(Model $authModel): bool
|
||||
{
|
||||
return UserStaticRules::atLeastRole($authModel, UserRoleRegistry::get('developper')->value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore the model.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Model $authModel
|
||||
* @return boolean
|
||||
*/
|
||||
public function restore(Model $authModel): bool
|
||||
{
|
||||
return UserStaticRules::atLeastRole($authModel, UserRoleRegistry::get('developper')->value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can soft delete the model.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Model $authModel
|
||||
* @return boolean
|
||||
*/
|
||||
public function delete(Model $authModel): bool
|
||||
{
|
||||
return UserStaticRules::atLeastRole($authModel, UserRoleRegistry::get('developper')->value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete the model.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Model $authModel
|
||||
* @return boolean
|
||||
*/
|
||||
public function forceDelete(Model $authModel): bool
|
||||
{
|
||||
return UserStaticRules::atLeastRole($authModel, UserRoleRegistry::get('developper')->value);
|
||||
}
|
||||
}
|
||||
31
database/factories/InvoiceCompanyFactory.php
Normal file
31
database/factories/InvoiceCompanyFactory.php
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\InvoiceCompany;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* Factory for generating InvoiceCompany model instances with randomized data.
|
||||
*/
|
||||
class InvoiceCompanyFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Associated model.
|
||||
*
|
||||
* @var class-string<\App\Models\InvoiceCompany>
|
||||
*/
|
||||
protected $model = InvoiceCompany::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
"name" => fake()->word(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -18,9 +18,9 @@ return new class extends Migration
|
|||
$table->string('title')->comment('Title of the notice.');
|
||||
$table->text('message')->comment('Message of the notice.');
|
||||
$table->unsignedTinyInteger('type')->comment('Type of the notice.');
|
||||
$table->timestamp('created_at')->nullable()->comment('Date the notice password was created.');
|
||||
$table->timestamp('updated_at')->nullable()->comment('Date the notice password was updated.');
|
||||
$table->timestamp('deleted_at')->nullable()->comment('Date the notice password was deleted.');
|
||||
$table->timestamp('created_at')->nullable()->comment('Date the notice was created.');
|
||||
$table->timestamp('updated_at')->nullable()->comment('Date the notice was updated.');
|
||||
$table->timestamp('deleted_at')->nullable()->comment('Date the notice was deleted.');
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,9 +18,9 @@ return new class extends Migration
|
|||
$table->string('name')->comment('Name of the invoice package.');
|
||||
$table->double('amount')->comment('Amount of the invoice package.');
|
||||
$table->boolean('published')->comment('Published status of the invoice package.');
|
||||
$table->timestamp('created_at')->nullable()->comment('Date the invoice package password was created.');
|
||||
$table->timestamp('updated_at')->nullable()->comment('Date the invoice package password was updated.');
|
||||
$table->timestamp('deleted_at')->nullable()->comment('Date the invoice package password was deleted.');
|
||||
$table->timestamp('created_at')->nullable()->comment('Date the invoice package was created.');
|
||||
$table->timestamp('updated_at')->nullable()->comment('Date the invoice package was updated.');
|
||||
$table->timestamp('deleted_at')->nullable()->comment('Date the invoice package was deleted.');
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('invoice_companies', function (Blueprint $table) {
|
||||
$table->id()->comment('Id of the invoice company.');
|
||||
$table->string('name')->comment('Name of the invoice company.');
|
||||
$table->timestamp('created_at')->nullable()->comment('Date the invoice company was created.');
|
||||
$table->timestamp('updated_at')->nullable()->comment('Date the invoice company was updated.');
|
||||
$table->timestamp('deleted_at')->nullable()->comment('Date the invoice company was deleted.');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('invoice_companies');
|
||||
}
|
||||
};
|
||||
25
database/seeders/Classic/InvoiceCompanySeeder.php
Normal file
25
database/seeders/Classic/InvoiceCompanySeeder.php
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders\Classic;
|
||||
|
||||
use App\Models\InvoiceCompany;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
/**
|
||||
* Seeds the invoice_companies table.
|
||||
*/
|
||||
class InvoiceCompanySeeder extends Seeder
|
||||
{
|
||||
/** @var string $table Associated table to this seeder. */
|
||||
public static string $table = 'invoice_companies';
|
||||
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
InvoiceCompany::factory(10)->create();
|
||||
}
|
||||
}
|
||||
|
|
@ -4,7 +4,8 @@ declare(strict_types=1);
|
|||
|
||||
return [
|
||||
"classes" => [
|
||||
"notices" => "information|informations",
|
||||
"invoice-packages" => "devis - forfait|devis - forfaits",
|
||||
"notices" => "information|informations",
|
||||
"invoice-packages" => "devis - forfait|devis - forfaits",
|
||||
"invoice-companies" => "devis - société|devis - sociétés",
|
||||
],
|
||||
];
|
||||
|
|
|
|||
|
|
@ -0,0 +1,73 @@
|
|||
// * Packages
|
||||
import { Building2Icon } from "lucide-react";
|
||||
import { route } from "ziggy-js";
|
||||
import { Link } from "@inertiajs/react";
|
||||
// * Components shadcn
|
||||
import { DropdownMenuItem } from "@/components/ui/dropdown-menu";
|
||||
import { Button } from "@/components/ui/button";
|
||||
// * Other
|
||||
import {
|
||||
filterActions,
|
||||
NavListLinksProps,
|
||||
} from "@/back/Components/Layout/Sidebar/AppSidebar";
|
||||
import { SidebarGroupLink } from "@/back/Components/Layout/Sidebar/SidebarRegistry";
|
||||
import { AuthProp } from "@/back/types/global";
|
||||
import str from "@/hooks/use-string";
|
||||
import { GetTranslation } from "@/lib/utils";
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
import Views from "@/back/lib/actions";
|
||||
|
||||
export default function SidebarLinkInvoiceCompanies(auth: AuthProp): SidebarGroupLink {
|
||||
const modelName = "invoice-companies";
|
||||
|
||||
// Translations.
|
||||
const transModel = GetTranslation(`models.classes.${modelName}`, {
|
||||
choice: 2,
|
||||
});
|
||||
const transCreate = str(
|
||||
useTrans(`uwil-backend::crud.actions.${Views.CREATION.label}`),
|
||||
)
|
||||
.ucFirst()
|
||||
.value();
|
||||
const transArchives = str(useTrans("uwil-backend::back.archives"))
|
||||
.ucFirst()
|
||||
.value();
|
||||
|
||||
const link: NavListLinksProps = {
|
||||
title: str(transModel).ucFirst().value(),
|
||||
model: modelName,
|
||||
icon: Building2Icon,
|
||||
show: auth.policies.invoiceCompanies.viewAny,
|
||||
actions: (model: string) =>
|
||||
filterActions({
|
||||
auth,
|
||||
model,
|
||||
items: [
|
||||
auth.policies.invoiceCompanies.create && (
|
||||
<DropdownMenuItem key="create" className="p-0">
|
||||
<Button variant="ghost" asChild>
|
||||
<Link href={route(`back.${model}.create`)} className="w-full">
|
||||
{/* eslint-disable-next-line react/jsx-pascal-case */}
|
||||
<Views.CREATION.icon />
|
||||
{transCreate}
|
||||
</Link>
|
||||
</Button>
|
||||
</DropdownMenuItem>
|
||||
),
|
||||
auth.policies.invoiceCompanies.viewTrash && (
|
||||
<DropdownMenuItem className="p-0">
|
||||
<Button variant="ghost" asChild>
|
||||
<Link href={route(`back.${model}.trash`)} className="w-full">
|
||||
{/* eslint-disable-next-line react/jsx-pascal-case */}
|
||||
<Views.ARCHIVATION.icon />
|
||||
{transArchives}
|
||||
</Link>
|
||||
</Button>
|
||||
</DropdownMenuItem>
|
||||
),
|
||||
],
|
||||
}),
|
||||
};
|
||||
|
||||
return { link, group: "modules" };
|
||||
}
|
||||
63
resources/ts/back/Pages/InvoiceCompanies/Create.tsx
Normal file
63
resources/ts/back/Pages/InvoiceCompanies/Create.tsx
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
// * Packages
|
||||
import { usePage } from "@inertiajs/react";
|
||||
import { route } from "ziggy-js";
|
||||
import { ArrowLeftIcon } from "lucide-react";
|
||||
// * Other
|
||||
import AuthenticatedLayout from "@/back/Layouts/AuthenticatedLayout";
|
||||
import Form from "@/back/Pages/InvoiceCompanies/Form";
|
||||
import BtnOptionnalLinkWithTooltip from "@/back/Components/BtnOptionnalLinkWithTooltip";
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
import { Actions, Methods } from "@/back/lib/enums";
|
||||
import { AuthProp, DefaultModel, SingleResource } from "@/back/types/global";
|
||||
|
||||
export default function Create({
|
||||
data,
|
||||
modelName,
|
||||
}: {
|
||||
data: SingleResource;
|
||||
modelName: string;
|
||||
}) {
|
||||
const { viewAny } = (usePage().props.auth as AuthProp).policies.invoiceCompanies;
|
||||
const model = data.data as DefaultModel;
|
||||
|
||||
// Translations.
|
||||
const transBackToList = useTrans("uwil-backend::back.crud_back_to_list");
|
||||
const transTitle = useTrans(
|
||||
route().current(`back.${modelName}.duplicate`)
|
||||
? "uwil-backend::crud.helpers.duplication_model"
|
||||
: "uwil-backend::crud.helpers.creation_model",
|
||||
{
|
||||
params: {
|
||||
model: useTrans(`models.classes.${modelName}`, {
|
||||
choice: 1,
|
||||
}),
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
const beforeNode = () => {
|
||||
return (
|
||||
viewAny && (
|
||||
<div className="flex justify-end items-center gap-x-1.5">
|
||||
<BtnOptionnalLinkWithTooltip
|
||||
link={route(`back.${modelName}.index`)}
|
||||
content={<ArrowLeftIcon />}
|
||||
tooltipContent={<p>{transBackToList}</p>}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<AuthenticatedLayout title={transTitle} beforeNode={beforeNode()}>
|
||||
<Form
|
||||
model={model}
|
||||
modelName={modelName}
|
||||
modelRoute={modelName}
|
||||
action={Actions.STORE}
|
||||
method={Methods.POST}
|
||||
/>
|
||||
</AuthenticatedLayout>
|
||||
);
|
||||
}
|
||||
71
resources/ts/back/Pages/InvoiceCompanies/Edit.tsx
Normal file
71
resources/ts/back/Pages/InvoiceCompanies/Edit.tsx
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
// * Packages
|
||||
import { usePage } from "@inertiajs/react";
|
||||
import { route } from "ziggy-js";
|
||||
import { ArrowLeftIcon } from "lucide-react";
|
||||
// * Other
|
||||
import AuthenticatedLayout from "@/back/Layouts/AuthenticatedLayout";
|
||||
import ModelActions from "@/back/Components/ModelActions";
|
||||
import BtnOptionnalLinkWithTooltip from "@/back/Components/BtnOptionnalLinkWithTooltip";
|
||||
import Form from "@/back/Pages/InvoiceCompanies/Form";
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
import { Actions, Methods } from "@/back/lib/enums";
|
||||
import { Views } from "@/back/lib/actions";
|
||||
import { AuthProp, DefaultModel, SingleResource } from "@/back/types/global";
|
||||
|
||||
export default function Edit({
|
||||
data,
|
||||
modelName,
|
||||
}: {
|
||||
data: SingleResource;
|
||||
modelName: string;
|
||||
}) {
|
||||
const { viewAny } = (usePage().props.auth as AuthProp).policies.invoiceCompanies;
|
||||
const model = data.data as DefaultModel;
|
||||
const actionModels = [
|
||||
Views.VISUALIZATION,
|
||||
Views.DUPLICATION,
|
||||
Views.ARCHIVATION,
|
||||
];
|
||||
|
||||
// Translations.
|
||||
const transBackToList = useTrans("uwil-backend::back.crud_back_to_list");
|
||||
const transTitle = useTrans("uwil-backend::crud.helpers.edition_model", {
|
||||
params: {
|
||||
model: useTrans(`models.classes.${modelName}`, {
|
||||
choice: 1,
|
||||
}),
|
||||
},
|
||||
});
|
||||
|
||||
const beforeNode = () => {
|
||||
return (
|
||||
viewAny && (
|
||||
<div className="flex justify-end items-center gap-x-1.5">
|
||||
<BtnOptionnalLinkWithTooltip
|
||||
link={route(`back.${modelName}.index`)}
|
||||
content={<ArrowLeftIcon />}
|
||||
tooltipContent={<p>{transBackToList}</p>}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<AuthenticatedLayout title={transTitle} beforeNode={beforeNode()}>
|
||||
<ModelActions
|
||||
actions={actionModels}
|
||||
modelRoute={modelName}
|
||||
model={model}
|
||||
modelUpdatedAt={model.updated_at.toString()}
|
||||
/>
|
||||
<Form
|
||||
model={model}
|
||||
modelName={modelName}
|
||||
modelRoute={modelName}
|
||||
action={Actions.UPDATE}
|
||||
method={Methods.PATCH}
|
||||
/>
|
||||
</AuthenticatedLayout>
|
||||
);
|
||||
}
|
||||
87
resources/ts/back/Pages/InvoiceCompanies/Form.tsx
Normal file
87
resources/ts/back/Pages/InvoiceCompanies/Form.tsx
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
// * Packages
|
||||
import { useForm, usePage } from "@inertiajs/react";
|
||||
import { BookTextIcon } from "lucide-react";
|
||||
// * Other
|
||||
import FieldsetWrapper from "@/back/Components/FieldsetWrapper";
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
import InputError from "@/back/Components/InputError";
|
||||
import SubmitButton from "@/back/Components/SubmitButton";
|
||||
import useCrudSubmit from "@/back/hooks/use-crud-submit";
|
||||
import SimpleString from "@/back/Components/Inputs/SimpleString";
|
||||
import str from "@/hooks/use-string";
|
||||
import { InvoiceCompanyModel } from "@/back/types/project";
|
||||
import { AppEnv } from "@/types/global";
|
||||
|
||||
export default function Form({
|
||||
model,
|
||||
modelName,
|
||||
modelRoute,
|
||||
action,
|
||||
method,
|
||||
}: {
|
||||
model?: InvoiceCompanyModel;
|
||||
modelName: string;
|
||||
modelRoute: string;
|
||||
action: string;
|
||||
method: number;
|
||||
}) {
|
||||
const { appEnv } = usePage().props as unknown as {
|
||||
appEnv: AppEnv;
|
||||
};
|
||||
|
||||
/** Form section */
|
||||
const { post, setData, data } = useForm({
|
||||
name: model?.name ? model?.name[appEnv.locale] : "",
|
||||
});
|
||||
|
||||
const submit = useCrudSubmit({
|
||||
method,
|
||||
modelRoute,
|
||||
modelName,
|
||||
action,
|
||||
model,
|
||||
post,
|
||||
data,
|
||||
modelNameTrans: useTrans(`models.classes.${modelName}`, {
|
||||
choice: 1,
|
||||
}),
|
||||
});
|
||||
|
||||
return (
|
||||
<form id="config-form" onSubmit={submit}>
|
||||
<InputError all />
|
||||
<FieldsetWrapper
|
||||
title={useTrans("uwil-backend::back.form_title_global")}
|
||||
icon={<BookTextIcon className="mr-1" />}
|
||||
description={useTrans("uwil-backend::back.form_subtitle_global")}
|
||||
className="sm:grid-cols-2 gap-4"
|
||||
>
|
||||
<SimpleString
|
||||
name="name"
|
||||
label={str(
|
||||
useTrans("uwil-backend::back.form_associate_to", {
|
||||
params: {
|
||||
attribute: useTrans(
|
||||
"validation.custom.name",
|
||||
),
|
||||
},
|
||||
choice: 1,
|
||||
}),
|
||||
)
|
||||
.ucFirst()
|
||||
.value()}
|
||||
placeholder="ex: John Doe"
|
||||
value={data.name}
|
||||
setData={setData}
|
||||
/>
|
||||
</FieldsetWrapper>
|
||||
<div className="text-center">
|
||||
<SubmitButton
|
||||
modelTrans={useTrans(`models.classes.${modelName}`, {
|
||||
choice: 1,
|
||||
})}
|
||||
/>
|
||||
</div>
|
||||
</form>
|
||||
);
|
||||
}
|
||||
163
resources/ts/back/Pages/InvoiceCompanies/Index.tsx
Normal file
163
resources/ts/back/Pages/InvoiceCompanies/Index.tsx
Normal file
|
|
@ -0,0 +1,163 @@
|
|||
// * Packages
|
||||
import { route } from "ziggy-js";
|
||||
import { usePage } from "@inertiajs/react";
|
||||
import { Row } from "@tanstack/react-table";
|
||||
import { ArchiveIcon, ArrowLeftIcon, PlusIcon } from "lucide-react";
|
||||
// * Components shadcn
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
// * Other
|
||||
import AuthenticatedLayout from "@/back/Layouts/AuthenticatedLayout";
|
||||
import DataTable from "@/back/Components/Table/DataTable";
|
||||
import DataTableSearch from "@/back/Components/Table/DataTableSearch";
|
||||
import DataTableFilterButton from "@/back/Components/Table/DataTableFilterButton";
|
||||
import SoftdeleteWarning from "@/back/Components/SoftdeleteWarning";
|
||||
import BtnOptionnalLinkWithTooltip from "@/back/Components/BtnOptionnalLinkWithTooltip";
|
||||
import { GetFormatedDate, GetTranslation } from "@/lib/utils";
|
||||
import { Views } from "@/back/lib/actions";
|
||||
import { AuthProp, DefaultModel, Resource } from "@/back/types/global";
|
||||
import str from "@/hooks/use-string";
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
import RenderTranslationCell from "@/back/Components/Table/RenderTranslationCell";
|
||||
import { InvoicePackageModel } from "@/back/types/project";
|
||||
|
||||
const getColumns = () => {
|
||||
return [
|
||||
{
|
||||
accessorKey: "name",
|
||||
header: ({ column }: { column: { id: string } }) => (
|
||||
<DataTableFilterButton
|
||||
label={str(
|
||||
GetTranslation(`validation.custom.${column.id}`),
|
||||
)
|
||||
.ucFirst()
|
||||
.value()}
|
||||
field={column.id}
|
||||
/>
|
||||
),
|
||||
cell: ({ row }: { row: Row<InvoicePackageModel> }) => (
|
||||
<RenderTranslationCell value={row.getValue("name")} />
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorKey: "updated_at",
|
||||
header: ({ column }: { column: { id: string } }) => (
|
||||
<DataTableFilterButton
|
||||
label={str(
|
||||
GetTranslation(`uwil-backend::validation.attributes.${column.id}`),
|
||||
)
|
||||
.ucFirst()
|
||||
.value()}
|
||||
field={column.id}
|
||||
/>
|
||||
),
|
||||
cell: ({ row }: { row: Row<DefaultModel> }) => (
|
||||
<Badge variant="secondary">
|
||||
{GetFormatedDate(row.getValue("updated_at"))}
|
||||
</Badge>
|
||||
),
|
||||
},
|
||||
];
|
||||
};
|
||||
|
||||
export default function Index({
|
||||
models,
|
||||
searchFields,
|
||||
modelName,
|
||||
}: {
|
||||
models: Resource;
|
||||
searchFields: string;
|
||||
modelName: string;
|
||||
}) {
|
||||
const { auth } = usePage().props as unknown as {
|
||||
auth: AuthProp;
|
||||
};
|
||||
const { viewAny, viewTrash, create } = auth.policies.invoiceCompanies;
|
||||
const isArchiveRoute = route().current(`back.${modelName}.trash`);
|
||||
const actionModels = isArchiveRoute
|
||||
? [Views.RESTORATION, Views.FORCEDELETION]
|
||||
: [
|
||||
Views.VISUALIZATION,
|
||||
Views.EDITION,
|
||||
Views.DUPLICATION,
|
||||
Views.ARCHIVATION,
|
||||
];
|
||||
const columns = getColumns();
|
||||
|
||||
// Translations.
|
||||
const transModel = useTrans(`models.classes.${modelName}`, { choice: 2 });
|
||||
const transArchiveTitle = useTrans(
|
||||
"uwil-backend::crud.helpers.archives_model",
|
||||
{
|
||||
params: { model: transModel },
|
||||
},
|
||||
);
|
||||
const transTitle = str(isArchiveRoute ? transArchiveTitle : transModel)
|
||||
.ucFirst()
|
||||
.value();
|
||||
const transCrudBackList = useTrans("uwil-backend::back.crud_back_to_list");
|
||||
|
||||
const beforeNode = () => {
|
||||
return (
|
||||
isArchiveRoute &&
|
||||
viewAny && (
|
||||
<div className="flex justify-end items-center gap-x-1.5">
|
||||
<BtnOptionnalLinkWithTooltip
|
||||
link={route(`back.${modelName}.index`)}
|
||||
content={<ArrowLeftIcon />}
|
||||
tooltipContent={<p>{transCrudBackList}</p>}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
);
|
||||
};
|
||||
const transCrudAddEntry = useTrans("uwil-backend::back.crud_add_entry");
|
||||
const transAccessTo = useTrans("uwil-backend::back.crud_access_to", {
|
||||
params: {
|
||||
target: useTrans("uwil-backend::back.archived_entries"),
|
||||
},
|
||||
});
|
||||
const afterNode = () => {
|
||||
return (
|
||||
!isArchiveRoute && (
|
||||
<div className="flex justify-end items-center gap-x-1.5">
|
||||
{viewTrash && (
|
||||
<BtnOptionnalLinkWithTooltip
|
||||
link={route(`back.${modelName}.trash`)}
|
||||
content={<ArchiveIcon />}
|
||||
tooltipContent={<p>{transAccessTo}</p>}
|
||||
variant="outline"
|
||||
/>
|
||||
)}
|
||||
{create && (
|
||||
<BtnOptionnalLinkWithTooltip
|
||||
link={route(`back.${modelName}.create`)}
|
||||
content={<PlusIcon />}
|
||||
tooltipContent={<p>{transCrudAddEntry}</p>}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<AuthenticatedLayout
|
||||
title={transTitle}
|
||||
beforeNode={beforeNode()}
|
||||
afterNode={afterNode()}
|
||||
>
|
||||
{isArchiveRoute && <SoftdeleteWarning />}
|
||||
<DataTableSearch
|
||||
modelRoute={modelName}
|
||||
searchFields={searchFields}
|
||||
isArchiveRoute={isArchiveRoute}
|
||||
/>
|
||||
<DataTable
|
||||
columns={columns}
|
||||
modelRoute={modelName}
|
||||
modelsPaginate={models}
|
||||
actions={actionModels}
|
||||
/>
|
||||
</AuthenticatedLayout>
|
||||
);
|
||||
}
|
||||
123
resources/ts/back/Pages/InvoiceCompanies/Show.tsx
Normal file
123
resources/ts/back/Pages/InvoiceCompanies/Show.tsx
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
// * Packages
|
||||
import { usePage } from "@inertiajs/react";
|
||||
import { route } from "ziggy-js";
|
||||
import { ArrowLeftIcon } from "lucide-react";
|
||||
// * Components shadcn
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
// * Other
|
||||
import AuthenticatedLayout from "@/back/Layouts/AuthenticatedLayout";
|
||||
import DetailsTable from "@/back/Components/Table/DetailsTable";
|
||||
import ModelActions from "@/back/Components/ModelActions";
|
||||
import BtnOptionnalLinkWithTooltip from "@/back/Components/BtnOptionnalLinkWithTooltip";
|
||||
import RenderTranslationCell from "@/back/Components/Table/RenderTranslationCell";
|
||||
import { GetFormatedDate, GetTranslation } from "@/lib/utils";
|
||||
import { Views } from "@/back/lib/actions";
|
||||
import { AuthProp, DefaultModel, SingleResource } from "@/back/types/global";
|
||||
import str from "@/hooks/use-string";
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
import { TranslationField } from "@/back/types/i18n";
|
||||
|
||||
const getColumns = () => {
|
||||
return [
|
||||
{
|
||||
accessorKey: "name",
|
||||
header: str(
|
||||
GetTranslation("validation.custom.name"),
|
||||
)
|
||||
.ucFirst()
|
||||
.value(),
|
||||
cell: ({ value }: { value: TranslationField }) => (
|
||||
<RenderTranslationCell value={value} />
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorKey: "created_at",
|
||||
header: str(
|
||||
GetTranslation("uwil-backend::validation.attributes.created_at"),
|
||||
)
|
||||
.ucFirst()
|
||||
.value(),
|
||||
cell: ({ value }: { value: string }) => (
|
||||
<Badge variant="secondary">{GetFormatedDate(value)}</Badge>
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorKey: "updated_at",
|
||||
header: str(
|
||||
GetTranslation("uwil-backend::validation.attributes.updated_at"),
|
||||
)
|
||||
.ucFirst()
|
||||
.value(),
|
||||
cell: ({ value }: { value: string }) => (
|
||||
<Badge variant="secondary">{GetFormatedDate(value)}</Badge>
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorKey: "deleted_at",
|
||||
header: str(
|
||||
GetTranslation("uwil-backend::validation.attributes.deleted_at"),
|
||||
)
|
||||
.ucFirst()
|
||||
.value(),
|
||||
cell: ({ value }: { value: string }) => (
|
||||
<Badge variant="secondary">{GetFormatedDate(value)}</Badge>
|
||||
),
|
||||
},
|
||||
];
|
||||
};
|
||||
|
||||
export default function Show({
|
||||
data,
|
||||
modelName,
|
||||
}: {
|
||||
data: SingleResource;
|
||||
modelName: string;
|
||||
}) {
|
||||
const { auth } = usePage().props as unknown as {
|
||||
auth: AuthProp;
|
||||
};
|
||||
const { viewAny } = auth.policies.invoiceCompanies;
|
||||
const model = data.data as DefaultModel;
|
||||
const actionModels = [Views.EDITION, Views.DUPLICATION, Views.ARCHIVATION];
|
||||
const transTitle = useTrans(
|
||||
"uwil-backend::crud.helpers.visualization_model",
|
||||
{
|
||||
params: {
|
||||
model: useTrans(`models.classes.${modelName}`, {
|
||||
choice: 1,
|
||||
}),
|
||||
},
|
||||
},
|
||||
);
|
||||
const columns = getColumns();
|
||||
|
||||
// Translations.
|
||||
const transCrudBackToList = useTrans("uwil-backend::back.crud_back_to_list");
|
||||
|
||||
const beforeNode = () => {
|
||||
return (
|
||||
viewAny && (
|
||||
<div className="flex justify-end items-center gap-x-1.5">
|
||||
<BtnOptionnalLinkWithTooltip
|
||||
link={route(`back.${modelName}.index`)}
|
||||
content={<ArrowLeftIcon />}
|
||||
tooltipContent={<p>{transCrudBackToList}</p>}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<AuthenticatedLayout title={transTitle} beforeNode={beforeNode()}>
|
||||
<ModelActions
|
||||
actions={actionModels}
|
||||
modelRoute={modelName}
|
||||
model={model}
|
||||
modelUpdatedAt={model.updated_at.toString()}
|
||||
/>
|
||||
{/* @ts-expect-error Weird error type on cell. */}
|
||||
<DetailsTable columns={columns} model={model} />
|
||||
</AuthenticatedLayout>
|
||||
);
|
||||
}
|
||||
|
|
@ -1,8 +1,6 @@
|
|||
// * Packages
|
||||
import { useForm, usePage } from "@inertiajs/react";
|
||||
import { BookTextIcon, EyeIcon } from "lucide-react";
|
||||
// * Components shadcn
|
||||
//
|
||||
// * Other
|
||||
import FieldsetWrapper from "@/back/Components/FieldsetWrapper";
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
// * Packages
|
||||
import { useForm, usePage } from "@inertiajs/react";
|
||||
import { BookTextIcon } from "lucide-react";
|
||||
// * Components shadcn
|
||||
//
|
||||
// * Other
|
||||
import FieldsetWrapper from "@/back/Components/FieldsetWrapper";
|
||||
import useTrans from "@/hooks/use-translations";
|
||||
|
|
|
|||
4
resources/ts/back/types/project.d.ts
vendored
4
resources/ts/back/types/project.d.ts
vendored
|
|
@ -12,3 +12,7 @@ type InvoicePackageModel = DefaultModel & {
|
|||
amount: number;
|
||||
published: boolean;
|
||||
};
|
||||
|
||||
type InvoiceCompanyModel = DefaultModel & {
|
||||
name: TranslationField;
|
||||
};
|
||||
|
|
|
|||
14
routes/back/invoice-companies.php
Normal file
14
routes/back/invoice-companies.php
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
|
||||
use App\Http\Controllers\Back\InvoiceCompanyController;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
Route::get('/invoice-companies/trash', [InvoiceCompanyController::class, 'index'])
|
||||
->name('invoice-companies.trash');
|
||||
Route::patch('/invoice-companies/{invoice_company}/restore', [InvoiceCompanyController::class, 'restore'])
|
||||
->name('invoice-companies.restore');
|
||||
Route::delete('/invoice-companies/{invoice_company}/force', [InvoiceCompanyController::class, 'forceDestroy'])
|
||||
->name('invoice-companies.forceDestroy');
|
||||
Route::resource('invoice-companies', InvoiceCompanyController::class);
|
||||
Route::get('/invoice-companies/{invoice_company}/duplicate', [InvoiceCompanyController::class, 'duplicate'])
|
||||
->name('invoice-companies.duplicate');
|
||||
39
routes/breadcrumbs/invoice-companies.php
Normal file
39
routes/breadcrumbs/invoice-companies.php
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
use Diglactic\Breadcrumbs\Breadcrumbs;
|
||||
use Diglactic\Breadcrumbs\Generator;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
Breadcrumbs::for('back.invoice-companies.index', function (Generator $trail) {
|
||||
$trail->push(
|
||||
Str::ucfirst(trans_choice('models.classes.invoice-companies', \INF)),
|
||||
route('back.invoice-companies.index')
|
||||
);
|
||||
});
|
||||
Breadcrumbs::for('back.invoice-companies.create', function (Generator $trail) {
|
||||
$trail->parent('back.invoice-companies.index');
|
||||
$trail->push(
|
||||
Str::ucfirst(trans_choice('models.classes.invoice-companies', 1)),
|
||||
route('back.invoice-companies.create')
|
||||
);
|
||||
});
|
||||
Breadcrumbs::for('back.invoice-companies.edit', function (Generator $trail) {
|
||||
$trail->parent('back.invoice-companies.index');
|
||||
$trail->push(Str::ucfirst(trans('uwil-backend::crud.actions.edit')), route('back.invoice-companies.edit', [
|
||||
'invoice_company' => request()->invoice_company
|
||||
]));
|
||||
});
|
||||
Breadcrumbs::for('back.invoice-companies.duplicate', function (Generator $trail) {
|
||||
$trail->parent('back.invoice-companies.index');
|
||||
$trail->push(Str::ucfirst(trans('uwil-backend::crud.actions.duplicate')));
|
||||
});
|
||||
Breadcrumbs::for('back.invoice-companies.show', function (Generator $trail) {
|
||||
$trail->parent('back.invoice-companies.index');
|
||||
$trail->push(Str::ucfirst(trans('uwil-backend::crud.actions.visualize')), route('back.invoice-companies.show', [
|
||||
'invoice_company' => request()->invoice_company
|
||||
]));
|
||||
});
|
||||
Breadcrumbs::for('back.invoice-companies.trash', function (Generator $trail) {
|
||||
$trail->parent('back.invoice-companies.index');
|
||||
$trail->push(Str::ucfirst(trans('uwil-backend::back.archives')));
|
||||
});
|
||||
Loading…
Add table
Reference in a new issue