Removed status from projects
This commit is contained in:
parent
c16871abb0
commit
24f7c1f73a
7 changed files with 32 additions and 74 deletions
|
|
@ -1,31 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Enums\Projects;
|
||||
|
||||
use App\Traits\Enums\BaseEnum;
|
||||
|
||||
enum ProjectStatusEnum: int
|
||||
{
|
||||
use BaseEnum;
|
||||
|
||||
case new = 0;
|
||||
case specification = 1;
|
||||
case validated = 2;
|
||||
case development = 3;
|
||||
case recipe = 4;
|
||||
case production = 5;
|
||||
case finished = 6;
|
||||
|
||||
/**
|
||||
* Optionnal labels definition
|
||||
*/
|
||||
private const LABELS = [
|
||||
self::new->name => "Nouveau",
|
||||
self::specification->name => "Spécifications",
|
||||
self::validated->name => "Validé",
|
||||
self::development->name => "En développement",
|
||||
self::recipe->name => "En recettage",
|
||||
self::production->name => "En production",
|
||||
self::finished->name => "Terminé",
|
||||
];
|
||||
}
|
||||
|
|
@ -2,10 +2,8 @@
|
|||
|
||||
namespace App\Http\Requests\Bo\Projects;
|
||||
|
||||
use App\Enums\Projects\ProjectStatusEnum;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class StoreProjectRequest extends FormRequest
|
||||
{
|
||||
|
|
@ -28,10 +26,6 @@ class StoreProjectRequest extends FormRequest
|
|||
{
|
||||
return [
|
||||
'name' => 'required|string|min:3|max:255|unique:projects,name',
|
||||
'status' => [
|
||||
'required',
|
||||
Rule::in(collect(ProjectStatusEnum::cases())->pluck('value')->all()),
|
||||
],
|
||||
'site_id' => 'required|exists:sites,id',
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,13 +2,11 @@
|
|||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\Projects\ProjectStatusEnum;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* @property string $name
|
||||
* @property ProjectStatusEnum $status
|
||||
* @property Site $site_id
|
||||
*/
|
||||
class Project extends Model
|
||||
|
|
@ -22,19 +20,9 @@ class Project extends Model
|
|||
*/
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'status',
|
||||
'site_id'
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast to native types.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts = [
|
||||
'status' => ProjectStatusEnum::class
|
||||
];
|
||||
|
||||
// * RELATIONSHIPS.
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -0,0 +1,32 @@
|
|||
<?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::table('projects', function (Blueprint $table) {
|
||||
$table->dropColumn('status');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('projects', function (Blueprint $table) {
|
||||
$table->unsignedSmallInteger('status')->default(0)->comment('Enum ProjectStatus')->after('name');
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
@ -32,25 +32,6 @@
|
|||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
{{-- STATUS --}}
|
||||
<div class="col-12 col-md-6 pb-3">
|
||||
<fieldset class="border h-100 bg-white p-3 mb-3">
|
||||
<legend>{{ Str::ucfirst(__('validation.attributes.status')) }}</legend>
|
||||
<div class="row">
|
||||
<div class="col-12 mb-3">
|
||||
@include('bo.partials.inputs.tinyint-enum', [
|
||||
'id' => 'projectStatus',
|
||||
'label' => __('crud.minicrud.associated', ['entity' => 'Role']),
|
||||
'name' => 'status',
|
||||
'model' => $projectModel ?? null,
|
||||
'required' => true,
|
||||
'associatedModels' => \App\Enums\Projects\ProjectStatusEnum::toArray(),
|
||||
'helper' => __('crud.minicrud.select', ['entity' => 'statut']),
|
||||
])
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
{{-- SITE_ID --}}
|
||||
<div class="col-12 col-md-6 pb-3">
|
||||
<fieldset class="border bg-white h-100 p-3">
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@
|
|||
@php
|
||||
$cols = [
|
||||
'name' => Str::ucfirst(__('validation.attributes.name')),
|
||||
'status' => Str::ucfirst(__('validation.attributes.status')),
|
||||
'site_id' => Str::ucfirst(__('models.classes.sites')),
|
||||
];
|
||||
@endphp
|
||||
|
|
@ -34,7 +33,6 @@
|
|||
@foreach ($projectModels as $projectModel)
|
||||
<tr class="list-item border-bottom">
|
||||
<td class="text-center align-middle">{{ $projectModel->name }}</td>
|
||||
<td class="text-center align-middle">{{ $projectModel->status->label() }}</td>
|
||||
<td class="text-center align-middle">{{ $projectModel->site->name }}</td>
|
||||
<td class="text-end align-middle">
|
||||
<form action="{{ route('bo.projects.destroy', $projectModel->id) }}"
|
||||
|
|
|
|||
|
|
@ -23,10 +23,6 @@
|
|||
<td class="text-center align-middle">{{ Str::ucfirst(__('validation.attributes.name')) }}</td>
|
||||
<td class="text-center align-middle">{{ $projectModel->name }}</td>
|
||||
</tr>
|
||||
<tr class="list-item border-bottom">
|
||||
<td class="text-center align-middle">{{ Str::ucfirst(__('validation.attributes.status')) }}</td>
|
||||
<td class="text-center align-middle">{{ $projectModel->status->label() }}</td>
|
||||
</tr>
|
||||
<tr class="list-item border-bottom">
|
||||
<td class="text-center align-middle">{{ Str::ucfirst(__('validation.attributes.sites')) }}</td>
|
||||
<td class="text-center align-middle">{{ $projectModel->site->name }}</td>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue