- Add status checker + admin secure packages + upgrade enum + add sentry + upgrade to sitemap generator + bump to CRMV2 - Set customer role enum and user role enum - Update customer migration to set roles - phpcbf - faker local to fr - update lang - composer update - bump laravel ui - Redo all user crud - npm bump - Create admin command - rearrange views - redo all auth system - redo customer pro bo
82 lines
2.6 KiB
PHP
82 lines
2.6 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Fo\Pro;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\Objectives;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
|
class ObjectivesController extends Controller
|
|
{
|
|
/**
|
|
* Remove the specified resource from storage.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function destroy(Request $request)
|
|
{
|
|
$deleteOk = 0;
|
|
|
|
if ($request->id !== null) {
|
|
$objectif = Objectives::findOrFail($request->id);
|
|
if ($objectif->customer_id == Auth::guard('frontend')->user()->id) {
|
|
$objectif->delete();
|
|
} else {
|
|
$deleteOk = 3;
|
|
}
|
|
} else {
|
|
$deleteOk = 2;
|
|
}
|
|
|
|
return $deleteOk;
|
|
}
|
|
|
|
/**
|
|
* Store a newly created resource or update an existing one
|
|
* @param \Illuminate\Http\Request $request
|
|
* @return array $objectif
|
|
*/
|
|
public function saveProDatas(Request $request)
|
|
{
|
|
// save data from Pro dashboard
|
|
$objectif = $request->objectif;
|
|
|
|
if (isset($objectif["id"])) {
|
|
$o = Objectives::findOrFail($objectif["id"]);
|
|
$o->produit = $objectif["produit"];
|
|
$o->qualite = $objectif["qualite"];
|
|
$o->quantite = $objectif["quantite"];
|
|
$o->campagne = $objectif["campagne"];
|
|
$o->prix = $objectif["prix"];
|
|
$o->echeance = $objectif["echeance"];
|
|
$o->volume_restant = $objectif["volume_restant"];
|
|
$o->observations = $objectif["observations"];
|
|
$o->save();
|
|
$objectif["status_id"] = $o->status_id;
|
|
$objectif["status"] = $o->status;
|
|
} else {
|
|
$o = Objectives::updateOrCreate([
|
|
'produit' => $objectif["produit"],
|
|
'qualite' => $objectif["qualite"],
|
|
'quantite' => $objectif["quantite"],
|
|
'campagne' => $objectif["campagne"],
|
|
'prix' => $objectif["prix"],
|
|
'echeance' => $objectif["echeance"],
|
|
'volume_restant' => $objectif["volume_restant"],
|
|
'observations' => $objectif["observations"],
|
|
'customer_id' => Auth::guard('frontend')->user()->id,
|
|
'status_id' => 1,
|
|
]);
|
|
$objectif["id"] = $o->id;
|
|
$objectif["status_id"] = $o->status_id;
|
|
$objectif["status"] = $o->status;
|
|
unset($objectif["customer_id"]);
|
|
} //end if
|
|
|
|
|
|
|
|
return $objectif;
|
|
}
|
|
}
|