diff --git a/app/Http/Controllers/Bo/ContentController.php b/app/Http/Controllers/Bo/ContentController.php
new file mode 100644
index 00000000..d5e844e9
--- /dev/null
+++ b/app/Http/Controllers/Bo/ContentController.php
@@ -0,0 +1,23 @@
+first();
+
+ if ($_SERVER["REQUEST_METHOD"] === "POST") {
+ $content->value = $request->value;
+ $content->save();
+
+ return redirect()->route('bo.content', ['key' => $content->key, 'content' => $content])->with('success', 'Modifications enregistrés !');
+ }
+
+ return view('bo.content.manage', compact('content'));
+ }
+}
diff --git a/app/Http/Controllers/Bo/FaqController.php b/app/Http/Controllers/Bo/FaqController.php
new file mode 100644
index 00000000..ccb32912
--- /dev/null
+++ b/app/Http/Controllers/Bo/FaqController.php
@@ -0,0 +1,46 @@
+faq;
+
+ for ($i = 0; $i < count($faq); $i++) {
+ $faqToInsert = !empty($faq[$i]["question"]) && !empty($faq[$i]["answer"]);
+ if (isset($faq[$i]["id"]) && $faq[$i]["id"] !== null && $faqToInsert) {
+ $f = Faq::findOrFail($faq[$i]["id"]);
+ $f->question = $faq[$i]["question"];
+ $f->answer = $faq[$i]["answer"];
+ $f->save();
+ } else {
+ if ($faqToInsert) {
+ $c = Faq::updateOrCreate(['question' => $faq[$i]["question"], 'answer' => $faq[$i]["answer"]]);
+ $faq[$i]["id"] = $c->id;
+ } else {
+ unset($faq[$i]);
+ $i--;
+ }
+ }
+ }
+
+ return $faq;
+ }
+
+ public function destroy(Request $request) {
+ $faq = Faq::findOrFail($request->id);
+ $faq->delete();
+
+ return "Suppression terminée !";
+ }
+}
diff --git a/app/Http/Controllers/Bo/SettingsController.php b/app/Http/Controllers/Bo/SettingsController.php
new file mode 100644
index 00000000..b084b318
--- /dev/null
+++ b/app/Http/Controllers/Bo/SettingsController.php
@@ -0,0 +1,28 @@
+key] = $setting->value;
+ }
+
+ if ($_SERVER["REQUEST_METHOD"] === "POST") {
+ for($i = 0; $i < count($settings); $i++) {
+ $settings[$i]->value = $request->input($settings[$i]->key) === null ? 0 : $request->input($settings[$i]->key);
+ $settings[$i]->save();
+ }
+ return redirect()->route('bo.settings')->with('success', 'Modifications enregistrés !');
+ }
+
+ return view('bo.settings', compact('settingsToPrint'));
+ }
+}
diff --git a/app/Http/Controllers/IndexController.php b/app/Http/Controllers/IndexController.php
index e835a7f4..c137f1b0 100644
--- a/app/Http/Controllers/IndexController.php
+++ b/app/Http/Controllers/IndexController.php
@@ -2,37 +2,45 @@
namespace App\Http\Controllers;
+use App\Models\Content;
+use App\Models\Faq;
use Illuminate\Http\Request;
class IndexController extends Controller
{
public function index(Request $request)
{
- return view('home');
+ $content = Content::where('key', 'accueil')->first();
+ return view('home', compact('content'));
}
public function contact(Request $request)
{
- return view('contact');
+ $content = Content::where('key', 'contact')->first();
+ return view('contact', compact('content'));
}
public function legalNotice(Request $request)
{
- return view('legal-notice');
+ $content = Content::where('key', 'legals')->first();
+ return view('legal-notice', compact('content'));
}
public function terms(Request $request)
{
- return view('terms');
+ $content = Content::where('key', 'cgv')->first();
+ return view('terms', compact('content'));
}
public function privacy(Request $request)
{
- return view('privacy');
+ $content = Content::where('key', 'confidentialite')->first();
+ return view('privacy', compact('content'));
}
public function faq(Request $request)
{
- return view('faq');
+ $faq = Faq::all();
+ return view('faq', compact('faq'));
}
}
diff --git a/app/Models/Content.php b/app/Models/Content.php
new file mode 100644
index 00000000..88bd87d3
--- /dev/null
+++ b/app/Models/Content.php
@@ -0,0 +1,13 @@
+id();
+ $table->string('key');
+ $table->text('value');
+ $table->timestamps();
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ Schema::dropIfExists('content');
+ }
+}
diff --git a/database/migrations/2020_11_04_132538_create_settings.php b/database/migrations/2020_11_04_132538_create_settings.php
new file mode 100644
index 00000000..a6bfe043
--- /dev/null
+++ b/database/migrations/2020_11_04_132538_create_settings.php
@@ -0,0 +1,33 @@
+id();
+ $table->string('key');
+ $table->string('value');
+ $table->timestamps();
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ Schema::dropIfExists('settings');
+ }
+}
diff --git a/database/migrations/2020_11_04_133603_create_faq.php b/database/migrations/2020_11_04_133603_create_faq.php
new file mode 100644
index 00000000..9d44b5cd
--- /dev/null
+++ b/database/migrations/2020_11_04_133603_create_faq.php
@@ -0,0 +1,33 @@
+id();
+ $table->string('question');
+ $table->text('answer');
+ $table->timestamps();
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ Schema::dropIfExists('faq');
+ }
+}
diff --git a/database/seeders/ContentSeeder.php b/database/seeders/ContentSeeder.php
new file mode 100644
index 00000000..d2d77bd4
--- /dev/null
+++ b/database/seeders/ContentSeeder.php
@@ -0,0 +1,42 @@
+key = 'accueil';
+ $accueil->value = "Page d'accueil";
+ $accueil->save();
+
+ $contact = new Content();
+ $contact->key = "contact";
+ $contact->value = "Nous contacter";
+ $contact->save();
+
+ $legals = new Content();
+ $legals->key = "legals";
+ $legals->value = "Mentions légales";
+ $legals->save();
+
+ $cgv = new Content();
+ $cgv->key = "cgv";
+ $cgv->value = "Conditions générales de ventes";
+ $cgv->save();
+
+ $confidentialite = new Content();
+ $confidentialite->key = "confidentialite";
+ $confidentialite->value = "Politique de confidentialité";
+ $confidentialite->save();
+ }
+}
diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php
index 57b73b54..986e475b 100644
--- a/database/seeders/DatabaseSeeder.php
+++ b/database/seeders/DatabaseSeeder.php
@@ -13,6 +13,7 @@ class DatabaseSeeder extends Seeder
*/
public function run()
{
- // \App\Models\User::factory(10)->create();
+ $this->call(ContentSeeder::class);
+ $this->call(SettingsSeeder::class);
}
}
diff --git a/database/seeders/SettingsSeeder.php b/database/seeders/SettingsSeeder.php
new file mode 100644
index 00000000..e98f9914
--- /dev/null
+++ b/database/seeders/SettingsSeeder.php
@@ -0,0 +1,42 @@
+key = "has_costs";
+ $hasCosts->value = "0";
+ $hasCosts->save();
+
+ $costs = new Settings();
+ $costs->key = "costs";
+ $costs->value = "0.00";
+ $costs->save();
+
+ $hasPayment = new Settings();
+ $hasPayment->key = "has_payment";
+ $hasPayment->value = "0";
+ $hasPayment->save();
+
+ $qrCode = new Settings();
+ $qrCode->key = "qr_code";
+ $qrCode->value = "0";
+ $qrCode->save();
+
+ $orderWithdrawalPeriod = new Settings();
+ $orderWithdrawalPeriod->key = "order_withdrawal_period";
+ $orderWithdrawalPeriod->value = "0";
+ $orderWithdrawalPeriod->save();
+ }
+}
diff --git a/package.json b/package.json
index 24fc592b..99f7332b 100644
--- a/package.json
+++ b/package.json
@@ -22,6 +22,7 @@
"vue-template-compiler": "^2.6.12"
},
"dependencies": {
- "sass": "^1.28.0"
+ "sass": "^1.28.0",
+ "vue": "^2.6.12"
}
}
diff --git a/resources/js/app.js b/resources/js/app.js
index 40c55f65..b6fd958c 100644
--- a/resources/js/app.js
+++ b/resources/js/app.js
@@ -1 +1,8 @@
require('./bootstrap');
+window.Vue = require('vue');
+
+Vue.component('faq', require('./components/Faq.vue').default);
+
+const app = new Vue({
+ el: '#app',
+});
diff --git a/resources/js/components/Faq.vue b/resources/js/components/Faq.vue
new file mode 100644
index 00000000..37232ed0
--- /dev/null
+++ b/resources/js/components/Faq.vue
@@ -0,0 +1,112 @@
+
+ FAQ
+
+
+
+
+
+
+
+ Question
+ Réponse
+
+
+
+
+
+
+
+
{{$f->answer}}
+ @endforeach @endsection diff --git a/resources/views/home.blade.php b/resources/views/home.blade.php index fd03436e..32fd0920 100644 --- a/resources/views/home.blade.php +++ b/resources/views/home.blade.php @@ -2,4 +2,5 @@ @section('content')