forked from dbarzin/mercator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
37 changed files
with
2,369 additions
and
651 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?php | ||
|
||
namespace App; | ||
|
||
use App\Document; | ||
use App\Process; | ||
use App\MApplication; | ||
use App\Information; | ||
|
||
use App\Traits\Auditable; | ||
use DateTimeInterface; | ||
use Illuminate\Database\Eloquent\Model; | ||
use Illuminate\Database\Eloquent\SoftDeletes; | ||
|
||
/** | ||
* App\Actor | ||
* | ||
*/ | ||
class DataProcessing extends Model | ||
{ | ||
use SoftDeletes, Auditable; | ||
|
||
public $table = 'data_processing'; | ||
|
||
public static $searchable = [ | ||
'name', | ||
'description', | ||
]; | ||
|
||
protected $dates = [ | ||
'created_at', | ||
'updated_at', | ||
'deleted_at', | ||
]; | ||
|
||
protected $fillable = [ | ||
'name', | ||
'description', | ||
'responsible', | ||
'purpose', | ||
'categories', | ||
'recipients', | ||
'transfert', | ||
'retention', | ||
'controls', | ||
]; | ||
|
||
|
||
public function processes() | ||
{ | ||
return $this->belongsToMany(Process::class)->orderBy('identifiant'); | ||
} | ||
|
||
public function applications() | ||
{ | ||
return $this->belongsToMany(MApplication::class)->orderBy('name'); | ||
} | ||
|
||
public function informations() | ||
{ | ||
return $this->belongsToMany(Information::class)->orderBy('name'); | ||
} | ||
|
||
public function documents() | ||
{ | ||
return $this->belongsToMany(Document::class); | ||
} | ||
|
||
protected function serializeDate(DateTimeInterface $date) | ||
{ | ||
return $date->format('Y-m-d H:i:s'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
109 changes: 109 additions & 0 deletions
109
app/Http/Controllers/Admin/DataProcessingController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\Admin; | ||
|
||
use App\Information; | ||
use App\MApplication; | ||
use App\Process; | ||
use App\DataProcessing; | ||
|
||
use App\Http\Controllers\Controller; | ||
use App\Http\Requests\MassDestroyDataProcessingRequest; | ||
use App\Http\Requests\StoreDataProcessingRequest; | ||
use App\Http\Requests\UpdateDataProcessingRequest; | ||
|
||
use Gate; | ||
|
||
use Symfony\Component\HttpFoundation\Response; | ||
|
||
class DataProcessingController extends Controller | ||
{ | ||
public function index() | ||
{ | ||
abort_if(Gate::denies('data_processing_register_access'), Response::HTTP_FORBIDDEN, '403 Forbidden'); | ||
|
||
$processingRegister = DataProcessing::orderBy('name')->get(); | ||
|
||
return view('admin.dataProcessing.index', compact('processingRegister')); | ||
} | ||
|
||
public function create() | ||
{ | ||
abort_if(Gate::denies('data_processing_register_create'), Response::HTTP_FORBIDDEN, '403 Forbidden'); | ||
|
||
$processes = Process::orderBy('identifiant')->get()->pluck('identifiant', 'id'); | ||
$informations = Information::orderBy('name')->get()->pluck('name', 'id'); | ||
$applications = MApplication::orderBy('name')->get()->pluck('name', 'id'); | ||
|
||
session()->put("documents",array()); | ||
|
||
return view('admin.dataProcessing.create', | ||
compact('applications', 'informations', 'processes')); | ||
} | ||
|
||
public function store(StoreDataProcessingRequest $request) | ||
{ | ||
$dataProcessing = DataProcessing::create($request->all()); | ||
$dataProcessing->processes()->sync($request->input('processes', [])); | ||
$dataProcessing->informations()->sync($request->input('informations', [])); | ||
$dataProcessing->applications()->sync($request->input('applications', [])); | ||
$dataProcessing->documents()->sync(session()->get("documents")); | ||
session()->forget("documents"); | ||
|
||
return redirect()->route('admin.data-processing.index'); | ||
} | ||
|
||
public function edit(DataProcessing $dataProcessing) | ||
{ | ||
abort_if(Gate::denies('data_processing_register_edit'), Response::HTTP_FORBIDDEN, '403 Forbidden'); | ||
|
||
$processes = Process::orderBy('identifiant')->get()->pluck('identifiant', 'id'); | ||
$informations = Information::orderBy('name')->get()->pluck('name', 'id'); | ||
$applications = MApplication::orderBy('name')->get()->pluck('name', 'id'); | ||
session()->put("documents", $dataProcessing->documents()->get()); | ||
|
||
//dd(session()->get("documents")); | ||
|
||
$dataProcessing->load('applications', 'informations', 'processes'); | ||
|
||
return view('admin.dataProcessing.edit', | ||
compact('dataProcessing', 'applications', 'informations', 'processes')); | ||
} | ||
|
||
public function update(UpdateDataProcessingRequest $request, DataProcessing $dataProcessing) | ||
{ | ||
$dataProcessing->update($request->all()); | ||
$dataProcessing->processes()->sync($request->input('processes', [])); | ||
$dataProcessing->applications()->sync($request->input('applications', [])); | ||
$dataProcessing->informations()->sync($request->input('informations', [])); | ||
$dataProcessing->documents()->sync(session()->get("documents")); | ||
session()->forget("documents"); | ||
|
||
return redirect()->route('admin.data-processing.index'); | ||
} | ||
|
||
public function show(DataProcessing $dataProcessing) | ||
{ | ||
abort_if(Gate::denies('data_processing_register_show'), Response::HTTP_FORBIDDEN, '403 Forbidden'); | ||
|
||
$dataProcessing->load('applications', 'informations', 'processes'); | ||
|
||
return view('admin.dataProcessing.show', compact('dataProcessing')); | ||
} | ||
|
||
public function destroy(DataProcessing $dataProcessing) | ||
{ | ||
abort_if(Gate::denies('data_processing_register_delete'), Response::HTTP_FORBIDDEN, '403 Forbidden'); | ||
|
||
$dataProcessing->delete(); | ||
|
||
return redirect()->route('admin.data-processing.index'); | ||
} | ||
|
||
public function massDestroy(MassDestroyDataProcessingRequest $request) | ||
{ | ||
DataProcessing::whereIn('id', request('ids'))->delete(); | ||
|
||
return response(null, Response::HTTP_NO_CONTENT); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.