diff --git a/app/Http/Controllers/CustomerController.php b/app/Http/Controllers/CustomerController.php
index c4631b1..55ed4d8 100644
--- a/app/Http/Controllers/CustomerController.php
+++ b/app/Http/Controllers/CustomerController.php
@@ -69,7 +69,6 @@ class CustomerController extends Controller
Session::remove("crud.$modelTable.sort_col");
}
-
if (request()->brand or Session::has("crud.$modelTable.brand")) {
$brand = $request->brand ?? Session::get("crud.$modelTable.brand");
Session::put("crud.$modelTable.brand", $brand);
@@ -194,7 +193,7 @@ class CustomerController extends Controller
});
} catch (\ErrorException $e) {
return redirect()->route('customers.index')
- ->with('error', trans('Le compte n\'as pas pu être supprimé.'));
+ ->with('error', trans('Le compte n\'a pas pu être supprimé.'));
} //end try
return redirect()->route('customers.index')->with('warning', trans('Compte supprimé.'));
diff --git a/app/Http/Controllers/QuestionController.php b/app/Http/Controllers/QuestionController.php
index def4f7d..12bfa81 100644
--- a/app/Http/Controllers/QuestionController.php
+++ b/app/Http/Controllers/QuestionController.php
@@ -4,14 +4,14 @@ namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use App\Http\Requests\QuestionExport;
+use App\Http\Requests\Questions\StoreQuestionRequest;
+use App\Http\Requests\Questions\UpdateQuestionRequest;
use App\Models\Brand;
use App\Models\Question;
use Carbon\Carbon;
-use Illuminate\Database\Eloquent\Builder;
+use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
-use Kwaadpepper\CrudPolicies\Http\Requests\CrudIndexRequest;
-use Kwaadpepper\CrudPolicies\Traits\CrudController;
use League\Csv\Writer;
use Symfony\Component\HttpFoundation\StreamedResponse;
@@ -20,48 +20,163 @@ use Symfony\Component\HttpFoundation\StreamedResponse;
*/
class QuestionController extends Controller
{
- use CrudController {
- index as crudIndex;
- }
-
- /** @var Question */
- public static $modelClass = Question::class;
-
- /**
- * The Bo app layout
- *
- * @var string
- */
- public static $layout = 'layouts.app';
-
- /**
- * Event index crud-policies
- *
- * @param Builder $query
- * @return Builder
- */
- public function indexQuery(Builder $query): Builder
- {
- if (request()->brand) {
- $query = $query->where('brand_id', '=', request()->brand);
- }
- return $query;
- }
-
/**
* Overload crud-policies index
*
- * @param CrudIndexRequest $request
+ * @param Request $request
* @return \Illuminate\Http\Response
*/
- public function index(CrudIndexRequest $request)
+ public function index(Request $request)
{
- /** @var \Illuminate\View\View */
- $view = $this->crudIndex($request);
- if ($request->ajax()) {
- return $view;
+ $modelTable = (new Question())->getTable();
+ $modelClass = Question::class;
+ $query = Question::query();
+
+ if ($request->brand) {
+ $query = $query->where('brand_id', '=', request()->brand);
}
- return view('question.index', $view->getData());
+ if ($request->search) {
+ $this->searchQuery(
+ $query,
+ $request->search,
+ null,
+ 'question',
+ );
+ }
+
+ $this->sortQuery($query);
+
+ /** @var \Illuminate\Pagination\AbstractPaginator */
+ $questionModels = $query->paginate(12);
+
+ return view('questions.index', compact(
+ 'modelClass',
+ 'modelTable',
+ 'questionModels'
+ ));
+ }
+
+ /**
+ * Show the form for creating a new resource.
+ *
+ * @param \App\Models\Question $question
+ * @return \Illuminate\Http\Response
+ */
+ public function create(Question $question)
+ {
+ $brandModels = Brand::get();
+
+ return view('questions.create', [
+ 'questionModel' => $question,
+ 'brandModels' => $brandModels
+ ]);
+ }
+
+ /**
+ * Store a newly created resource in storage.
+ *
+ * @param \App\Http\Requests\Questions\StoreQuestionRequest $request
+ * @return \Illuminate\Http\Response
+ */
+ public function store(StoreQuestionRequest $request)
+ {
+ return DB::transaction(function () use ($request) {
+ $question = new Question();
+ $question->fill($request->validated());
+ if ($question->saveOrFail()) {
+ return redirect()
+ ->route('questions.edit', $question)
+ ->with('success', trans(
+ ':model a été créé.',
+ ['model' => Str::singular(trans('models.classes.questions'))]
+ ));
+ }
+ return redirect()
+ ->back()
+ ->with('error', trans(
+ ':model n\'a pas été créé.',
+ ['model' => Str::singular(trans('models.classes.questions'))]
+ ));
+ });
+ }
+
+ /**
+ * Show the form for editing the specified resource.
+ *
+ * @param \App\Models\Question $question
+ * @return \Illuminate\Http\Response
+ */
+ public function edit(Question $question)
+ {
+ $brandModels = Brand::get();
+
+ return view('questions.edit', [
+ 'questionModel' => $question,
+ 'brandModels' => $brandModels
+ ]);
+ }
+
+ /**
+ * Update a spacific resource in storage.
+ *
+ * @param \App\Http\Requests\Questions\UpdateQuestionRequest $request
+ * @param \App\Models\Question $question
+ * @return \Illuminate\Http\Response
+ */
+ public function update(UpdateQuestionRequest $request, Question $question)
+ {
+ return DB::transaction(function () use ($request, $question) {
+ $question->fill($request->validated());
+ if ($question->saveOrFail()) {
+ return redirect()
+ ->route('questions.edit', $question)
+ ->with('success', trans(
+ ':model a été mis à jour.',
+ ['model' => Str::singular(trans('models.classes.questions'))]
+ ));
+ }
+ return redirect()
+ ->back()
+ ->with('error', trans(
+ ':model n\'a pas été mis à jour.',
+ ['model' => Str::singular(trans('models.classes.questions'))]
+ ));
+ });
+ }
+
+ /**
+ * Show the specified resource.
+ *
+ * @param \App\Models\Question $question
+ * @return \Illuminate\Http\Response
+ */
+ public function show(Question $question)
+ {
+ return view('questions.show', [
+ 'questionModel' => $question
+ ]);
+ }
+
+ /**
+ * Remove the specified resource from storage.
+ *
+ * @param \App\Models\Question $question
+ * @return \Illuminate\Http\RedirectResponse
+ */
+ public function destroy(Question $question): \Illuminate\Http\RedirectResponse
+ {
+ if ($question->deleteOrFail()) {
+ return redirect()->route('questions.index')
+ ->with('success', trans(
+ ':model a été supprimé.',
+ ['model' => Str::singular(trans('models.classes.questions'))]
+ ));
+ }
+ return redirect()->back()
+ ->with('error', trans(
+ ':model n\'a pas pu être supprimé.',
+ ['model' => Str::singular(trans('models.classes.questions'))]
+ ));
}
/**
@@ -72,7 +187,21 @@ class QuestionController extends Controller
public function export()
{
$brands = Brand::all();
- return view('question.export', compact('brands'));
+ return view('questions.export', compact('brands'));
+ }
+
+ /**
+ * Store a newly created resource in storage.
+ *
+ * @return \Illuminate\Http\Response
+ */
+ public function jsonPaginate()
+ {
+ return DB::transaction(function () {
+ /** @var \App\Models\Tag */
+ $brandModels = Brand::paginate(12);
+ return \response()->json($brandModels ?? 500);
+ });
}
/**
diff --git a/app/Http/Requests/Questions/StoreQuestionRequest.php b/app/Http/Requests/Questions/StoreQuestionRequest.php
new file mode 100644
index 0000000..af8e054
--- /dev/null
+++ b/app/Http/Requests/Questions/StoreQuestionRequest.php
@@ -0,0 +1,44 @@
+check();
+ }
+
+ /**
+ * Get the validation rules that apply to the request.
+ *
+ * @return array
+ */
+ public function rules(): array
+ {
+ return [
+ 'question' => 'required|string|min:5|max:255',
+ 'type' => 'required|integer|min:0',
+ 'brand_id' => 'required|integer|min:0',
+ ];
+ }
+
+ /**
+ * Get custom attributes for validator errors.
+ *
+ * @return array
+ */
+ public function attributes(): array
+ {
+ return [
+ 'name' => trans('Nom de la marque'),
+ ];
+ }
+}
diff --git a/app/Http/Requests/Questions/UpdateQuestionRequest.php b/app/Http/Requests/Questions/UpdateQuestionRequest.php
new file mode 100644
index 0000000..7e0e1f0
--- /dev/null
+++ b/app/Http/Requests/Questions/UpdateQuestionRequest.php
@@ -0,0 +1,7 @@
+=8.0.0"
+ }
+ },
"node_modules/sockjs": {
"version": "0.3.24",
"resolved": "https://registry.npmjs.org/sockjs/-/sockjs-0.3.24.tgz",
@@ -11688,6 +11737,15 @@
"webpack": "^4.1.0 || ^5.0.0-0"
}
},
+ "node_modules/vue-select": {
+ "version": "4.0.0-beta.3",
+ "resolved": "https://registry.npmjs.org/vue-select/-/vue-select-4.0.0-beta.3.tgz",
+ "integrity": "sha512-sXufbTDluz26a39UUZE9jeh9Hojnn8zr9qDDUlVEBc7E0F+h3+Nzy8YzyFHuVNrrYLmK0zrPkb7hWFulAEW41Q==",
+ "dev": true,
+ "peerDependencies": {
+ "vue": "3.x"
+ }
+ },
"node_modules/vue-style-loader": {
"version": "4.1.3",
"resolved": "https://registry.npmjs.org/vue-style-loader/-/vue-style-loader-4.1.3.tgz",
@@ -14152,6 +14210,44 @@
"integrity": "sha512-AZU7vQcy/4WFEuwnwsNsJnFwupIpbllH1++LXScN6uxT1Z4zPzdrWG97w4/I7eFKFTvfy/bHFStWjdBAg2Vjug==",
"dev": true
},
+ "@types/vue-select": {
+ "version": "3.16.2",
+ "resolved": "https://registry.npmjs.org/@types/vue-select/-/vue-select-3.16.2.tgz",
+ "integrity": "sha512-KkmQiNI7Cei2YV3wn7O2fmM6PpfuM9ybYFMDqq2AvIZNZ2BRHMMV70yaa1EKBRvqu5qY5ekel5WzcRRfNu56PQ==",
+ "dev": true,
+ "requires": {
+ "vue": "^2.0.0"
+ },
+ "dependencies": {
+ "@vue/compiler-sfc": {
+ "version": "2.7.14",
+ "resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-2.7.14.tgz",
+ "integrity": "sha512-aNmNHyLPsw+sVvlQFQ2/8sjNuLtK54TC6cuKnVzAY93ks4ZBrvwQSnkkIh7bsbNhum5hJBS00wSDipQ937f5DA==",
+ "dev": true,
+ "requires": {
+ "@babel/parser": "^7.18.4",
+ "postcss": "^8.4.14",
+ "source-map": "^0.6.1"
+ }
+ },
+ "vue": {
+ "version": "2.7.14",
+ "resolved": "https://registry.npmjs.org/vue/-/vue-2.7.14.tgz",
+ "integrity": "sha512-b2qkFyOM0kwqWFuQmgd4o+uHGU7T+2z3T+WQp8UBjADfEv2n4FEMffzBmCKNP0IGzOEEfYjvtcC62xaSKeQDrQ==",
+ "dev": true,
+ "requires": {
+ "@vue/compiler-sfc": "2.7.14",
+ "csstype": "^3.1.0"
+ }
+ }
+ }
+ },
+ "@types/webpack-env": {
+ "version": "1.18.1",
+ "resolved": "https://registry.npmjs.org/@types/webpack-env/-/webpack-env-1.18.1.tgz",
+ "integrity": "sha512-D0HJET2/UY6k9L6y3f5BL+IDxZmPkYmPT4+qBrRdmRLYRuV0qNKizMgTvYxXZYn+36zjPeoDZAEYBCM6XB+gww==",
+ "dev": true
+ },
"@types/ws": {
"version": "8.5.5",
"resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.5.5.tgz",
@@ -20031,6 +20127,12 @@
"is-fullwidth-code-point": "^3.0.0"
}
},
+ "slugify": {
+ "version": "1.6.6",
+ "resolved": "https://registry.npmjs.org/slugify/-/slugify-1.6.6.tgz",
+ "integrity": "sha512-h+z7HKHYXj6wJU+AnS/+IH8Uh9fdcX1Lrhg1/VMdf9PwoBQXFcXiAdsy2tSK0P6gKwJLXp02r90ahUCqHk9rrw==",
+ "dev": true
+ },
"sockjs": {
"version": "0.3.24",
"resolved": "https://registry.npmjs.org/sockjs/-/sockjs-0.3.24.tgz",
@@ -21002,6 +21104,13 @@
"loader-utils": "^2.0.0"
}
},
+ "vue-select": {
+ "version": "4.0.0-beta.3",
+ "resolved": "https://registry.npmjs.org/vue-select/-/vue-select-4.0.0-beta.3.tgz",
+ "integrity": "sha512-sXufbTDluz26a39UUZE9jeh9Hojnn8zr9qDDUlVEBc7E0F+h3+Nzy8YzyFHuVNrrYLmK0zrPkb7hWFulAEW41Q==",
+ "dev": true,
+ "requires": {}
+ },
"vue-style-loader": {
"version": "4.1.3",
"resolved": "https://registry.npmjs.org/vue-style-loader/-/vue-style-loader-4.1.3.tgz",
diff --git a/package.json b/package.json
index ebe1d14..74299f4 100644
--- a/package.json
+++ b/package.json
@@ -20,6 +20,8 @@
"@fortawesome/free-solid-svg-icons": "^6.4.0",
"@rushstack/eslint-patch": "^1.3.1",
"@types/bootstrap": "^5.2.6",
+ "@types/vue-select": "^3.16.2",
+ "@types/webpack-env": "^1.18.1",
"@typescript-eslint/eslint-plugin": "^5.59.9",
"@typescript-eslint/parser": "^5.59.9",
"@vue/eslint-config-typescript": "^11.0.3",
@@ -41,6 +43,7 @@
"resolve-url-loader": "^3.1.3",
"sass": "^1.32.11",
"sass-loader": "^11.0.1",
+ "slugify": "^1.6.6",
"stylelint": "^14.11.0",
"stylelint-config-idiomatic-order": "^8.1.0",
"stylelint-config-prettier": "^9.0.5",
@@ -54,6 +57,7 @@
"typescript-eslint": "^0.0.1-alpha.0",
"vue": "^3.2.38",
"vue-eslint-parser": "^9.1.0",
- "vue-loader": "^16.8.3"
+ "vue-loader": "^16.8.3",
+ "vue-select": "^4.0.0-beta.3"
}
}
diff --git a/resources/ts/app.ts b/resources/ts/app.ts
index a3f655f..cbeb87d 100644
--- a/resources/ts/app.ts
+++ b/resources/ts/app.ts
@@ -5,6 +5,7 @@ import "./utilities/vue";
// CUSTOM
import "./pages/customer.delete";
+import "./pages/data.delete";
import "./pages/service.index";
import "./pages/single_optin.index";
import "./pages/statsExport";
diff --git a/resources/ts/components/InputTextAutoComponent.vue b/resources/ts/components/InputTextAutoComponent.vue
new file mode 100644
index 0000000..a374eca
--- /dev/null
+++ b/resources/ts/components/InputTextAutoComponent.vue
@@ -0,0 +1,111 @@
+
+