feat: Add project manager on site model - Close #79
This commit is contained in:
parent
bf6f35fdb1
commit
0bca962de9
9 changed files with 112 additions and 4 deletions
|
|
@ -9,6 +9,7 @@ use App\Lib\Helpers\ToolboxHelper;
|
|||
use App\Models\Site;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
|
|
@ -23,7 +24,7 @@ class SiteController extends Controller
|
|||
public function index(Request $request): \Illuminate\Contracts\View\View
|
||||
{
|
||||
/** @var \App\Models\User $user */
|
||||
$user = \auth()->user();
|
||||
$user = Auth::user();
|
||||
|
||||
if ($user->isAdmin()) {
|
||||
/** @var \Illuminate\Database\Eloquent\Builder $siteModels */
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ class StoreSiteRequest extends FormRequest
|
|||
'users' => 'nullable|array',
|
||||
'users.*.id' => 'required|exists:users,id',
|
||||
'gitlab_project_id' => 'nullable|unique:sites,gitlab_project_id',
|
||||
'project_manager_id' => 'nullable|exists:users,id',
|
||||
'url_re7' => 'nullable|url',
|
||||
'url_prod' => 'nullable|url'
|
||||
];
|
||||
|
|
@ -46,6 +47,7 @@ class StoreSiteRequest extends FormRequest
|
|||
'users' => trans('Utilisateurs associés au site'),
|
||||
'users.*.id' => trans('Élément parmis les Utilisateurs associés au site'),
|
||||
'gitlab_project_id' => trans('ID du dépôt Gitlab'),
|
||||
'project_manager_id' => trans('Chef de projet'),
|
||||
'url_re7' => trans('Url de RECETTE'),
|
||||
'url_prod' => trans('Url de prod')
|
||||
];
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ use App\Lib\Helpers\ToolboxHelper;
|
|||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
/**
|
||||
|
|
@ -29,7 +30,8 @@ class Site extends Model
|
|||
'name',
|
||||
'url_re7',
|
||||
'url_prod',
|
||||
'gitlab_project_id'
|
||||
'gitlab_project_id',
|
||||
'project_manager_id'
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
@ -109,6 +111,17 @@ class Site extends Model
|
|||
return $this->belongsTo(Brand::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* BelongsTo User relation
|
||||
* The project manager of the site
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function projectManager(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'project_manager_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* BelongsTo Project relation
|
||||
*
|
||||
|
|
|
|||
|
|
@ -0,0 +1,38 @@
|
|||
<?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('sites', function (Blueprint $table) {
|
||||
$table->unsignedBigInteger('project_manager_id')
|
||||
->nullable()
|
||||
->after('brand_id')
|
||||
->comment('Project manager relationship');
|
||||
|
||||
$table->foreign('project_manager_id')->references('id')->on('users')->nullOnDelete();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('sites', function (Blueprint $table) {
|
||||
$table->dropForeign(['project_manager_id']);
|
||||
$table->dropColumn('project_manager_id');
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
@ -59,12 +59,14 @@
|
|||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
{{-- GITLAB_PROJECT_ID --}}
|
||||
<div class="col-12 col-md-6 mb-3">
|
||||
<fieldset class="h-100 border bg-white p-3">
|
||||
<legend>{{ Str::ucfirst(__('validation.attributes.gitlab_project_id')) }}</legend>
|
||||
<div class="row">
|
||||
<div class="col-12 mb-3">
|
||||
<div class="col-12">
|
||||
@include('bo.partials.inputs.int-number', [
|
||||
'id' => 'siteGitlabProject',
|
||||
'label' => __(':field du :model', [
|
||||
|
|
@ -86,6 +88,30 @@
|
|||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
{{-- PROJECT MANAGER --}}
|
||||
<div class="col-12 col-md-6 pb-3">
|
||||
<fieldset class="h-100 mb-3 border bg-white p-3">
|
||||
<legend>{{ __('Chef de projet') }}</legend>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<label for="project_manager" class="col-form-label">
|
||||
<b>{{ __('Chef de projet') }}</b>
|
||||
</label>
|
||||
<select class="form-select" id="project_manager" name="project_manager_id">
|
||||
<option></option>
|
||||
@foreach (\App\Models\User::adminUsers() as $user)
|
||||
<option value="{{ $user->id }}"
|
||||
@if (intval(old('project_manager_id', ($siteModel and $siteModel->project_manager_id) ? $siteModel->project_manager_id : 0)) == $user->id) selected="selected" @endif>
|
||||
{{ $user->name }}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
{{-- SITE URLS --}}
|
||||
<div class="col-12 mb-3">
|
||||
<fieldset class="row w-100 h-100 mx-auto border bg-white p-3">
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@
|
|||
'name' => Str::ucfirst(__('validation.attributes.name')),
|
||||
'url_re7' => Str::ucfirst(__('validation.attributes.url_re7')),
|
||||
'url_prod' => Str::ucfirst(__('validation.attributes.url_prod')),
|
||||
'project_manager_id' => __("Chef de projet"),
|
||||
],
|
||||
])
|
||||
</thead>
|
||||
|
|
@ -46,6 +47,13 @@
|
|||
-
|
||||
@endif
|
||||
</td>
|
||||
<td class="text-center align-middle">
|
||||
@if ($siteModel->project_manager_id)
|
||||
{{ $siteModel->projectManager->name }}
|
||||
@else
|
||||
-
|
||||
@endif
|
||||
</td>
|
||||
@can('isAdmin')
|
||||
<td class="text-end align-middle">
|
||||
<form action="{{ route('bo.sites.destroy', $siteModel->id) }}"
|
||||
|
|
|
|||
|
|
@ -81,6 +81,16 @@
|
|||
@endif
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="list-item border-bottom">
|
||||
<td class="text-center align-middle">{{ __("Chef de projet") }}</td>
|
||||
<td class="text-center align-middle">
|
||||
@if ($siteModel->project_manager_id)
|
||||
{{ $siteModel->projectManager->name }}
|
||||
@else
|
||||
-
|
||||
@endif
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="list-item border-bottom">
|
||||
<td class="text-center align-middle">{{ Str::ucfirst(__('validation.attributes.created_at')) }}</td>
|
||||
<td class="text-center align-middle"><span class="badge bg-info">{{ $siteModel->created_at }}</span></td>
|
||||
|
|
|
|||
|
|
@ -16,6 +16,14 @@
|
|||
(Archivés)
|
||||
@endif
|
||||
</h1>
|
||||
@if (session('tickets.pr'))
|
||||
@php
|
||||
$projectManager = \App\Models\Site::query()->find(session('tickets.pr'))->projectManager;
|
||||
@endphp
|
||||
@if($projectManager)
|
||||
<h2>{{ __("Chef de projet") }} : {{ $projectManager->name; }}</h2>
|
||||
@endif
|
||||
@endif
|
||||
</div>
|
||||
<div class="col">
|
||||
<a class="btn btn-primary float-end" href="{{ route('bo.ticket.create') }}">
|
||||
|
|
|
|||
|
|
@ -104,7 +104,9 @@
|
|||
@endif
|
||||
<div>
|
||||
<h4>
|
||||
{{ __('Suivi') }}
|
||||
@if ($ticket->site->projectManager)
|
||||
{{ __("Chef de projet") }} : {{ $ticket->site->projectManager->name }}
|
||||
@endif
|
||||
@can('createMessage', $ticket)
|
||||
<button class="btn btn-sm btn-primary float-end mx-1" data-bs-toggle="modal" data-bs-target="#messageModal" type="button">
|
||||
{{ __('Répondre') }}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue