Ajout des moments (menu "En ce moment")
This commit is contained in:
parent
f619d9111d
commit
2e7c13ee28
7 changed files with 801 additions and 3 deletions
235
app/Http/Controllers/Bo/MomentsController.php
Normal file
235
app/Http/Controllers/Bo/MomentsController.php
Normal file
|
|
@ -0,0 +1,235 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Bo;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Str;
|
||||
use App\Models\Moments;
|
||||
use App\Models\Recipes;
|
||||
|
||||
class MomentsController extends Controller
|
||||
{
|
||||
private $colors = [
|
||||
"color-1" => "Couleur 1",
|
||||
"color-2" => 'Couleur 2',
|
||||
"color-3" => 'Couleur 3',
|
||||
"color-4" => "Couleur 4",
|
||||
"color-5" => "Couleur 5",
|
||||
"color-6" => "Couleur 6",
|
||||
"color-7" => "Couleur 7",
|
||||
"color-8" => "Couleur 8",
|
||||
];
|
||||
|
||||
private $featuredTypes = [
|
||||
"recettes" => "Recettes",
|
||||
"produits" => "Produits",
|
||||
"articles" => "Articles",
|
||||
];
|
||||
|
||||
public function index()
|
||||
{
|
||||
$m = Moments::all();
|
||||
return view('bo.moments.index', compact('m'));
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
$r = Recipes::all();
|
||||
return view('bo.moments.create', compact('r'))
|
||||
->with('colors', $this->colors)
|
||||
->with('featuredTypes', $this->featuredTypes)
|
||||
;
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$title = $request->title;
|
||||
$description = $request->description;
|
||||
$color = $request->color;
|
||||
$picture = $request->picture;
|
||||
$picture_bg = $request->picture_bg;
|
||||
$picture_bg_r = $request->picture_bg_r;
|
||||
$parallax = $request->parallax === null ? 0 : 1;
|
||||
$starMoment = $request->star_moment === null ? 0 : 1;
|
||||
$status = 0;
|
||||
$featuredTitle = $request->featured_title;
|
||||
$featuredText = $request->featured_text;
|
||||
$featuredType = $request->featured_type;
|
||||
$featuredIds = $request->featured_ids;
|
||||
$featuredStatus = $request->featured_status === null ? 0 : 1;
|
||||
$voucherPicture = $request->voucher_picture;
|
||||
$voucherStatus = $request->voucher_status === null ? 0 : 1;
|
||||
|
||||
$request->validate([
|
||||
'title' => 'required|max:150',
|
||||
'description' => 'required|max:400',
|
||||
'color' => 'required|max:7',
|
||||
'picture' => 'image|mimes:jpeg,png,jpg|max:2048|dimensions:width=750,height=400',
|
||||
'picture_bg' => 'image|mimes:jpeg,png,jpg|max:2048|dimensions:width=1200,height=750',
|
||||
'picture_bg_r' => 'image|mimes:jpeg,png,jpg|max:2048|dimensions:width=500,height=300',
|
||||
'featured_title' => 'required|max:150',
|
||||
'featured_text' => 'required|max:4000',
|
||||
'voucher_picture' => 'image|mimes:jpeg,png,jpg|max:2048|dimensions:width=580,height=330',
|
||||
]);
|
||||
|
||||
$featuredIdsString = '';
|
||||
foreach ($featuredIds as $featuredId) {
|
||||
$featuredIdsString .= $featuredId . ';';
|
||||
}
|
||||
|
||||
$imageName = Str::slug($title) . '-le-gaulois.'.$picture->extension();
|
||||
$picture->move(public_path('images/moments/' . date('Y') . '/' . date('m') . '/'), $imageName);
|
||||
$imageName_bg = Str::slug($title) . '-bg-le-gaulois.' . $picture_bg->extension();
|
||||
$picture_bg->move(public_path('images/moments/' . date('Y') . '/' . date('m') . '/'), $imageName_bg);
|
||||
$imageName_bg_r = Str::slug($title) . '-bg-r-le-gaulois.' . $picture_bg_r->extension();
|
||||
$picture_bg_r->move(public_path('images/moments/' . date('Y') . '/' . date('m') . '/'), $imageName_bg_r);
|
||||
$imageNameVoucher = Str::slug($title) . '-bon-reduction-le-gaulois.' . $voucherPicture->extension();
|
||||
$voucherPicture->move(public_path('images/moments/' . date('Y') . '/' . date('m') . '/'), $imageNameVoucher);
|
||||
|
||||
$m = new Moments();
|
||||
$m->title = $title;
|
||||
$m->description = $description;
|
||||
$m->color = $color;
|
||||
$m->picture = date('Y') . '/' . date('m') . '/' . $imageName;
|
||||
$m->picture_bg = date('Y') . '/' . date('m') . '/' . $imageName_bg;
|
||||
$m->picture_bg_r = date('Y') . '/' . date('m') . '/' . $imageName_bg_r;
|
||||
$m->parallax = $parallax;
|
||||
$m->star_moment = $starMoment;
|
||||
$m->status = $status;
|
||||
$m->featured_title = $featuredTitle;
|
||||
$m->featured_text = $featuredText;
|
||||
$m->featured_type = $featuredType;
|
||||
$m->featured_ids = $featuredIdsString;
|
||||
$m->featured_status = $featuredStatus;
|
||||
$m->voucher_picture = date('Y') . '/' . date('m') . '/' . $imageNameVoucher;
|
||||
$m->voucher_status = $voucherStatus;
|
||||
$m->save();
|
||||
|
||||
return redirect()->route('bo.moments.index');
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$m = Moments::findOrFail($id);
|
||||
$r = Recipes::all();
|
||||
return view('bo.moments.edit', compact('m', 'r'))
|
||||
->with('colors', $this->colors)
|
||||
->with('featuredTypes', $this->featuredTypes)
|
||||
;
|
||||
}
|
||||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
$title = $request->title;
|
||||
$description = $request->description;
|
||||
$color = $request->color;
|
||||
$picture = $request->picture;
|
||||
$picture_bg = $request->picture_bg;
|
||||
$picture_bg_r = $request->picture_bg_r;
|
||||
$parallax = $request->parallax === null ? 0 : 1;
|
||||
$starMoment = $request->star_moment === null ? 0 : 1;
|
||||
$status = $request->status === null ? 0 : 1;
|
||||
$featuredTitle = $request->featured_title;
|
||||
$featuredText = $request->featured_text;
|
||||
$featuredType = $request->featured_type;
|
||||
$featuredIds = $request->featured_ids;
|
||||
$featuredStatus = $request->featured_status === null ? 0 : 1;
|
||||
$voucherPicture = $request->voucher_picture;
|
||||
$voucherStatus = $request->voucher_status === null ? 0 : 1;
|
||||
|
||||
$request->validate([
|
||||
'title' => 'required|max:150',
|
||||
'description' => 'required|max:400',
|
||||
'color' => 'required|max:7',
|
||||
'featured_title' => 'required|max:150',
|
||||
'featured_text' => 'required|max:4000',
|
||||
]);
|
||||
|
||||
|
||||
if ($picture !== null) {
|
||||
$request->validate([
|
||||
'picture' => 'image|mimes:jpeg,png,jpg|max:2048|dimensions:width=750,height=400',
|
||||
]);
|
||||
}
|
||||
if ($picture_bg !== null) {
|
||||
$request->validate([
|
||||
'picture_bg' => 'image|mimes:jpeg,png,jpg|max:2048|dimensions:width=1200,height=750',
|
||||
]);
|
||||
}
|
||||
if ($picture_bg_r !== null) {
|
||||
$request->validate([
|
||||
'picture_bg_r' => 'image|mimes:jpeg,png,jpg|max:2048|dimensions:width=500,height=300',
|
||||
]);
|
||||
}
|
||||
if ($voucherPicture !== null) {
|
||||
$request->validate([
|
||||
'voucher_picture' => 'image|mimes:jpeg,png,jpg|max:2048|dimensions:width=580,height=330',
|
||||
]);
|
||||
}
|
||||
|
||||
$featuredIdsString = '';
|
||||
foreach ($featuredIds as $featuredId) {
|
||||
$featuredIdsString .= $featuredId . ';';
|
||||
}
|
||||
|
||||
$m = Moments::findOrFail($id);
|
||||
|
||||
if ($picture !== null) {
|
||||
if (file_exists(public_path('images/moments/') . $m->picture))
|
||||
unlink(public_path('images/moments/') . $m->picture);
|
||||
$imageName = Str::slug($title) . '-le-gaulois.'.$picture->extension();
|
||||
$picture->move(public_path('images/moments/' . date('Y') . '/' . date('m') . '/'), $imageName);
|
||||
}
|
||||
|
||||
if ($picture_bg !== null) {
|
||||
if (file_exists(public_path('images/moments/') . $m->picture_bg))
|
||||
unlink(public_path('images/moments/') . $m->picture_bg);
|
||||
$imageName_bg = Str::slug($title) . '-bg-le-gaulois.' . $picture_bg->extension();
|
||||
$picture_bg->move(public_path('images/moments/' . date('Y') . '/' . date('m') . '/'), $imageName_bg);
|
||||
}
|
||||
|
||||
if ($picture_bg_r !== null) {
|
||||
if (file_exists(public_path('images/moments/') . $m->picture_bg_r))
|
||||
unlink(public_path('images/moments/') . $m->picture_bg_r);
|
||||
$imageName_bg_r = Str::slug($title) . '-bg-r-le-gaulois.' . $picture_bg_r->extension();
|
||||
$picture_bg_r->move(public_path('images/moments/' . date('Y') . '/' . date('m') . '/'), $imageName_bg_r);
|
||||
}
|
||||
|
||||
if ($voucherPicture !== null) {
|
||||
if (file_exists(public_path('images/moments/') . $m->voucher_picture))
|
||||
unlink(public_path('images/moments/') . $m->voucher_picture);
|
||||
$imageNameVoucher = Str::slug($title) . '-bon-reduction-le-gaulois.' . $voucherPicture->extension();
|
||||
$voucherPicture->move(public_path('images/moments/' . date('Y') . '/' . date('m') . '/'), $imageNameVoucher);
|
||||
}
|
||||
|
||||
$m->title = $title;
|
||||
$m->description = $description;
|
||||
$m->color = $color;
|
||||
if ($picture !== null)
|
||||
$m->picture = date('Y') . '/' . date('m') . '/' . $imageName;
|
||||
if ($picture_bg !== null)
|
||||
$m->picture_bg = date('Y') . '/' . date('m') . '/' . $imageName_bg;
|
||||
if ($picture_bg_r !== null)
|
||||
$m->picture_bg_r = date('Y') . '/' . date('m') . '/' . $imageName_bg_r;
|
||||
$m->parallax = $parallax;
|
||||
$m->star_moment = $starMoment;
|
||||
$m->status = $status;
|
||||
$m->featured_title = $featuredTitle;
|
||||
$m->featured_text = $featuredText;
|
||||
$m->featured_type = $featuredType;
|
||||
$m->featured_ids = $featuredIdsString;
|
||||
$m->featured_status = $featuredStatus;
|
||||
if ($voucherPicture !== null)
|
||||
$m->voucher_picture = date('Y') . '/' . date('m') . '/' . $imageNameVoucher;
|
||||
$m->voucher_status = $voucherStatus;
|
||||
$m->save();
|
||||
|
||||
return redirect()->route('bo.moments.edit', $m->id)->with('success', 'Enregistré !');
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
10
app/Models/Moments.php
Normal file
10
app/Models/Moments.php
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Moments extends Model
|
||||
{
|
||||
//
|
||||
}
|
||||
219
resources/views/bo/moments/create.blade.php
Normal file
219
resources/views/bo/moments/create.blade.php
Normal file
|
|
@ -0,0 +1,219 @@
|
|||
@extends('layouts.bo')
|
||||
|
||||
@section('styles')
|
||||
<style>
|
||||
.color-padding {
|
||||
padding-left: 8px;
|
||||
padding-right: 8px;
|
||||
padding-top: 0px;
|
||||
padding-bottom: 0px;
|
||||
margin-right: 5px;
|
||||
margin-left: 5px;
|
||||
border: 1px solid #EFEBE9;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.color-selected {
|
||||
border: 1px solid #64DD17;
|
||||
border-radius: 4px;
|
||||
}
|
||||
</style>
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
Ajout d'un moment
|
||||
<a href="{{route('bo.moments.index')}}" class="btn btn-sm btn-primary float-right">Retour</a>
|
||||
</div>
|
||||
<form action="{{route('bo.moments.store')}}" method="POST" enctype="multipart/form-data">
|
||||
@csrf
|
||||
@if ($errors->any())
|
||||
<div class="alert alert-danger">
|
||||
<ul>
|
||||
@foreach ($errors->all() as $error)
|
||||
<li>{{ $error }}</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
</div>
|
||||
@endif
|
||||
<ul class="list-group list-group-flush">
|
||||
<li class="list-group-item"><em>Champs généraux</em></li>
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<div class="col-md-10 offset-md-1">
|
||||
<div class="form-group">
|
||||
<input class="form-control" type="text" name="title" placeholder="Titre *" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input class="form-control" type="text" name="description" placeholder="Description *" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<select class="custom-select" id="color" name="color">
|
||||
@foreach ($colors as $idColor => $nameColor)
|
||||
<option value="{{$idColor}}">{{$nameColor}}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group row col-md-12 offset-md-1">
|
||||
<input class="col-md-1 color-padding" id="i-color-1" type="color" value="#9BBCE3" disabled>
|
||||
<input class="col-md-1 color-padding" id="i-color-2" type="color" value="#FBBF2F" disabled>
|
||||
<input class="col-md-1 color-padding" id="i-color-3" type="color" value="#B94D5F" disabled>
|
||||
<input class="col-md-1 color-padding" id="i-color-4" type="color" value="#E6A748" disabled>
|
||||
<input class="col-md-1 color-padding" id="i-color-5" type="color" value="#F2C4DA" disabled>
|
||||
<input class="col-md-1 color-padding" id="i-color-6" type="color" value="#E28845" disabled>
|
||||
<input class="col-md-1 color-padding" id="i-color-7" type="color" value="#D6B17C" disabled>
|
||||
<input class="col-md-1 color-padding" id="i-color-8" type="color" value="#A3CAB1" disabled>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Visuel * de type JPEG/PNG - 2Mo max. - 750 x 400px</label></br>
|
||||
<input type="file" name="picture" accept="image/png, image/jpeg" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Visuel background * de type JPEG/PNG - 2Mo max. - 1200 x 750px</label></br>
|
||||
<input type="file" name="picture_bg" accept="image/png, image/jpeg" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Visuel background mobile * de type JPEG/PNG - 2Mo max. - 500 x 300px</label></br>
|
||||
<input type="file" name="picture_bg_r" accept="image/png, image/jpeg" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-form-label">
|
||||
<input type="checkbox" name="parallax">
|
||||
Activer le parallax ?
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-form-label">
|
||||
<input type="checkbox" name="star_moment">
|
||||
Moment star ?
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<li class="list-group-item"><em>Strates générales</em></li>
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<div class="col-md-10 offset-md-1">
|
||||
{{-- TODO : Strate à faire en Vue.js --}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<li class="list-group-item"><em>Strate de la remontée</em></li>
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<div class="col-md-10 offset-md-1">
|
||||
<div class="form-group">
|
||||
<input class="form-control" type="text" name="featured_title" placeholder="Titre de la remontée *" required>
|
||||
</div>
|
||||
{{-- TODO : Mettre un CKEditor à la place du textarea featured_text --}}
|
||||
<div class="form-group">
|
||||
<textarea class="form-control" name="featured_text" placeholder="Texte de la remontée *" required></textarea>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label class="col-form-label col-md-4">Type de remontée</label>
|
||||
<select class="custom-select col-md-8" id="featured_type" name="featured_type">
|
||||
@foreach ($featuredTypes as $idType => $nomType)
|
||||
<option value="{{$idType}}">{{$nomType}}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
{{-- TODO : Liste Recettes/Produits/Articles en ajax --}}
|
||||
<div class="form-group row">
|
||||
<label class="col-form-label col-md-4" id="featured_1"></label>
|
||||
<select class="custom-select col-md-8" name="featured_ids[]">
|
||||
@foreach ($r as $recipe)
|
||||
<option value="{{$recipe->id}}">{{$recipe->title}}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
<label class="col-form-label col-md-4" id="featured_2"></label>
|
||||
<select class="custom-select col-md-8" name="featured_ids[]">
|
||||
@foreach ($r as $recipe)
|
||||
<option value="{{$recipe->id}}">{{$recipe->title}}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
<label class="col-form-label col-md-4" id="featured_3"></label>
|
||||
<select class="custom-select col-md-8" name="featured_ids[]">
|
||||
@foreach ($r as $recipe)
|
||||
<option value="{{$recipe->id}}">{{$recipe->title}}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-form-label">
|
||||
<input type="checkbox" name="featured_status">
|
||||
Activer les remontées ?
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<li class="list-group-item"><em>Strate de bons de réduction</em></li>
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<div class="col-md-10 offset-md-1">
|
||||
<div class="form-group">
|
||||
<label>Visuel du bon de réduction * de type JPEG/PNG - 2Mo max. - 580 x 330px</label></br>
|
||||
<input type="file" name="voucher_picture" accept="image/png, image/jpeg" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-form-label">
|
||||
<input type="checkbox" name="voucher_status">
|
||||
Activer la strate BR ?
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-group text-center">
|
||||
<input type="submit" class="btn btn-secondary" value="Ajouter">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</ul>
|
||||
</form>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@section('scripts')
|
||||
<script type="text/javascript">
|
||||
// Pour enregistré la couleur précédement choisie
|
||||
var previous = '';
|
||||
|
||||
$(document).ready(function() {
|
||||
$("#featured_1").text(($("#featured_type").val()).slice(0, -1) + " 1");
|
||||
$('#featured_1').css('textTransform', 'capitalize');
|
||||
|
||||
$("#featured_2").text(($("#featured_type").val()).slice(0, -1) + " 2");
|
||||
$('#featured_2').css('textTransform', 'capitalize');
|
||||
|
||||
$("#featured_3").text(($("#featured_type").val()).slice(0, -1) + " 3");
|
||||
$('#featured_3').css('textTransform', 'capitalize');
|
||||
|
||||
previous = $("#color").val();
|
||||
$("#i-" + $("#color").val()).addClass("color-selected");
|
||||
});
|
||||
|
||||
// Modifie les labels des remontées quand le type de remontée change
|
||||
$("#featured_type").change(function() {
|
||||
$("#featured_1").text(($("#featured_type").val()).slice(0, -1) + " 1");
|
||||
$('#featured_1').css('textTransform', 'capitalize');
|
||||
|
||||
$("#featured_2").text(($("#featured_type").val()).slice(0, -1) + " 2");
|
||||
$('#featured_2').css('textTransform', 'capitalize');
|
||||
|
||||
$("#featured_3").text(($("#featured_type").val()).slice(0, -1) + " 3");
|
||||
$('#featured_3').css('textTransform', 'capitalize');
|
||||
});
|
||||
|
||||
// Récup l'ancienne valeur choisi dans les couleurs
|
||||
$("#color").on('focus', function () {
|
||||
previous = this.value;
|
||||
}).change(function() {
|
||||
$("#i-" + previous).removeClass("color-selected");
|
||||
$("#i-" + $("#color").val()).addClass("color-selected");
|
||||
|
||||
previous = this.value;
|
||||
});
|
||||
</script>
|
||||
@endsection
|
||||
289
resources/views/bo/moments/edit.blade.php
Normal file
289
resources/views/bo/moments/edit.blade.php
Normal file
|
|
@ -0,0 +1,289 @@
|
|||
@extends('layouts.bo')
|
||||
|
||||
@section('styles')
|
||||
<style>
|
||||
.color-padding {
|
||||
padding-left: 8px;
|
||||
padding-right: 8px;
|
||||
padding-top: 0px;
|
||||
padding-bottom: 0px;
|
||||
margin-right: 5px;
|
||||
margin-left: 5px;
|
||||
border: 1px solid #EFEBE9;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.color-selected {
|
||||
border: 1px solid #64DD17;
|
||||
border-radius: 4px;
|
||||
}
|
||||
</style>
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
Modification d'un moment
|
||||
<a href="{{route('bo.moments.index')}}" class="btn btn-sm btn-primary float-right ml-2">Retour</a>
|
||||
<form action="{{route('bo.moments.destroy', $m->id)}}" method="POST" class="d-inline">
|
||||
@method('DELETE')
|
||||
@csrf
|
||||
<input type="submit" class="btn btn-sm btn-danger float-right" value="Supprimer"
|
||||
onclick="return confirm('Êtes-vous sûr(e) ?')">
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<form action="{{route('bo.moments.update', $m->id)}}" method="POST" enctype="multipart/form-data">
|
||||
@method('PUT')
|
||||
@csrf
|
||||
@if (session('success'))
|
||||
<div class="alert alert-success">
|
||||
{{ session('success') }}
|
||||
</div>
|
||||
@endif
|
||||
@if ($errors->any())
|
||||
<div class="alert alert-danger">
|
||||
<ul>
|
||||
@foreach ($errors->all() as $error)
|
||||
<li>{{ $error }}</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
</div>
|
||||
@endif
|
||||
<ul class="list-group list-group-flush">
|
||||
<li class="list-group-item"><em>Champs généraux</em></li>
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<div class="col-md-10 offset-md-1">
|
||||
<div class="form-group">
|
||||
<input class="form-control" type="text" name="title" placeholder="Titre *" value="{{$m->title}}" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input class="form-control" type="text" name="description" placeholder="Description *" value="{{$m->description}}" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<select class="custom-select" id="color" name="color">
|
||||
@foreach ($colors as $idColor => $nameColor)
|
||||
@if ($idColor === $m->color)
|
||||
<option value="{{$idColor}}" selected>{{$nameColor}}</option>
|
||||
@else
|
||||
<option value="{{$idColor}}">{{$nameColor}}</option>
|
||||
@endif
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group row col-md-12 offset-md-1">
|
||||
<input class="col-md-1 color-padding" id="i-color-1" type="color" value="#9BBCE3" disabled>
|
||||
<input class="col-md-1 color-padding" id="i-color-2" type="color" value="#FBBF2F" disabled>
|
||||
<input class="col-md-1 color-padding" id="i-color-3" type="color" value="#B94D5F" disabled>
|
||||
<input class="col-md-1 color-padding" id="i-color-4" type="color" value="#E6A748" disabled>
|
||||
<input class="col-md-1 color-padding" id="i-color-5" type="color" value="#F2C4DA" disabled>
|
||||
<input class="col-md-1 color-padding" id="i-color-6" type="color" value="#E28845" disabled>
|
||||
<input class="col-md-1 color-padding" id="i-color-7" type="color" value="#D6B17C" disabled>
|
||||
<input class="col-md-1 color-padding" id="i-color-8" type="color" value="#A3CAB1" disabled>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Visuel * de type JPEG/PNG - 2Mo max. - 750 x 400px</label></br>
|
||||
<input type="file" name="picture" accept="image/png, image/jpeg">
|
||||
</br>
|
||||
</br>
|
||||
<img src="/images/moments/{{$m->picture}}" style="max-height: 200px;">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Visuel background * de type JPEG/PNG - 2Mo max. - 1200 x 750px</label></br>
|
||||
<input type="file" name="picture_bg" accept="image/png, image/jpeg">
|
||||
</br>
|
||||
</br>
|
||||
<img src="/images/moments/{{$m->picture_bg}}" style="max-height: 200px;">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Visuel background mobile * de type JPEG/PNG - 2Mo max. - 500 x 300px</label></br>
|
||||
<input type="file" name="picture_bg_r" accept="image/png, image/jpeg">
|
||||
</br>
|
||||
</br>
|
||||
<img src="/images/moments/{{$m->picture_bg_r}}" style="max-height: 200px;">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-form-label">
|
||||
@if ($m->parallax === 1)
|
||||
<input type="checkbox" name="parallax" checked>
|
||||
@else
|
||||
<input type="checkbox" name="parallax">
|
||||
@endif
|
||||
Activer le parallax ?
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-form-label">
|
||||
@if ($m->star_moment === 1)
|
||||
<input type="checkbox" name="star_moment" checked>
|
||||
@else
|
||||
<input type="checkbox" name="star_moment">
|
||||
@endif
|
||||
Moment star ?
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-form-label">
|
||||
@if ($m->status === 1)
|
||||
<input type="checkbox" name="status" checked>
|
||||
@else
|
||||
<input type="checkbox" name="status">
|
||||
@endif
|
||||
Publié ?
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<li class="list-group-item"><em>Strates générales</em></li>
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<div class="col-md-10 offset-md-1">
|
||||
{{-- TODO : Strate à faire en Vue.js --}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<li class="list-group-item"><em>Strate de la remontée</em></li>
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<div class="col-md-10 offset-md-1">
|
||||
<div class="form-group">
|
||||
<input class="form-control" type="text" name="featured_title" placeholder="Titre de la remontée *" value="{{$m->featured_title}}" required>
|
||||
</div>
|
||||
{{-- TODO : Mettre un CKEditor à la place du textarea featured_text --}}
|
||||
<div class="form-group">
|
||||
<textarea class="form-control" name="featured_text" placeholder="Texte de la remontée *" required>{{$m->featured_text}}</textarea>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label class="col-form-label col-md-4">Type de remontée</label>
|
||||
<select class="custom-select col-md-8" id="featured_type" name="featured_type">
|
||||
@foreach ($featuredTypes as $idType => $nomType)
|
||||
@if ($idType === $m->featured_type)
|
||||
<option value="{{$idType}}" selected>{{$nomType}}</option>
|
||||
@else
|
||||
<option value="{{$idType}}">{{$nomType}}</option>
|
||||
@endif
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
{{-- TODO : Liste Recettes/Produits/Articles en ajax, que recettes qui fonctionne pour le moment --}}
|
||||
<div class="form-group row">
|
||||
<label class="col-form-label col-md-4" id="featured_1"></label>
|
||||
<select class="custom-select col-md-8" name="featured_ids[]">
|
||||
@foreach ($r as $recipe)
|
||||
@if ($recipe->id == explode(';', $m->featured_ids)[0])
|
||||
<option value="{{$recipe->id}}"selected>{{$recipe->title}}</option>
|
||||
@else
|
||||
<option value="{{$recipe->id}}">{{$recipe->title}}</option>
|
||||
@endif
|
||||
@endforeach
|
||||
</select>
|
||||
<label class="col-form-label col-md-4" id="featured_2"></label>
|
||||
<select class="custom-select col-md-8" name="featured_ids[]">
|
||||
@foreach ($r as $recipe)
|
||||
@if ($recipe->id == explode(';', $m->featured_ids)[1])
|
||||
<option value="{{$recipe->id}}"selected>{{$recipe->title}}</option>
|
||||
@else
|
||||
<option value="{{$recipe->id}}">{{$recipe->title}}</option>
|
||||
@endif
|
||||
@endforeach
|
||||
</select>
|
||||
<label class="col-form-label col-md-4" id="featured_3"></label>
|
||||
<select class="custom-select col-md-8" name="featured_ids[]">
|
||||
@foreach ($r as $recipe)
|
||||
@if ($recipe->id == explode(';', $m->featured_ids)[2])
|
||||
<option value="{{$recipe->id}}"selected>{{$recipe->title}}</option>
|
||||
@else
|
||||
<option value="{{$recipe->id}}">{{$recipe->title}}</option>
|
||||
@endif
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-form-label">
|
||||
@if ($m->featured_status === 1)
|
||||
<input type="checkbox" name="featured_status" checked>
|
||||
@else
|
||||
<input type="checkbox" name="featured_status">
|
||||
@endif
|
||||
Activer les remontées ?
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<li class="list-group-item"><em>Strate de bons de réduction</em></li>
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<div class="col-md-10 offset-md-1">
|
||||
<div class="form-group">
|
||||
<label>Visuel du bon de réduction * de type JPEG/PNG - 2Mo max. - 580 x 330px</label></br>
|
||||
<input type="file" name="voucher_picture" accept="image/png, image/jpeg">
|
||||
</br>
|
||||
</br>
|
||||
<img src="/images/moments/{{$m->voucher_picture}}" style="max-height: 200px;">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-form-label">
|
||||
@if ($m->voucher_status === 1)
|
||||
<input type="checkbox" name="voucher_status" checked>
|
||||
@else
|
||||
<input type="checkbox" name="voucher_status">
|
||||
@endif
|
||||
Activer la strate BR ?
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-group text-center">
|
||||
<input type="submit" class="btn btn-secondary" value="Modifier">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</ul>
|
||||
</form>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@section('scripts')
|
||||
<script type="text/javascript">
|
||||
// Pour enregistré la couleur précédement choisie
|
||||
var previous = '';
|
||||
|
||||
$(document).ready(function() {
|
||||
$("#featured_1").text(($("#featured_type").val()).slice(0, -1) + " 1");
|
||||
$('#featured_1').css('textTransform', 'capitalize');
|
||||
|
||||
$("#featured_2").text(($("#featured_type").val()).slice(0, -1) + " 2");
|
||||
$('#featured_2').css('textTransform', 'capitalize');
|
||||
|
||||
$("#featured_3").text(($("#featured_type").val()).slice(0, -1) + " 3");
|
||||
$('#featured_3').css('textTransform', 'capitalize');
|
||||
|
||||
previous = $("#color").val();
|
||||
$("#i-" + $("#color").val()).addClass("color-selected");
|
||||
});
|
||||
|
||||
// Modifie les labels des remontées quand le type de remontée change
|
||||
$("#featured_type").change(function() {
|
||||
$("#featured_1").text(($("#featured_type").val()).slice(0, -1) + " 1");
|
||||
$('#featured_1').css('textTransform', 'capitalize');
|
||||
|
||||
$("#featured_2").text(($("#featured_type").val()).slice(0, -1) + " 2");
|
||||
$('#featured_2').css('textTransform', 'capitalize');
|
||||
|
||||
$("#featured_3").text(($("#featured_type").val()).slice(0, -1) + " 3");
|
||||
$('#featured_3').css('textTransform', 'capitalize');
|
||||
});
|
||||
|
||||
// Récup l'ancienne valeur choisi dans les couleurs
|
||||
$("#color").on('focus', function () {
|
||||
previous = this.value;
|
||||
}).change(function() {
|
||||
$("#i-" + previous).removeClass("color-selected");
|
||||
$("#i-" + $("#color").val()).addClass("color-selected");
|
||||
|
||||
previous = this.value;
|
||||
});
|
||||
</script>
|
||||
@endsection
|
||||
37
resources/views/bo/moments/index.blade.php
Normal file
37
resources/views/bo/moments/index.blade.php
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
@extends('layouts.bo')
|
||||
|
||||
@section('content')
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
Liste des moments
|
||||
<a href="{{route('bo.moments.create')}}" class="btn btn-sm btn-primary float-right">Ajouter</a>
|
||||
</div>
|
||||
|
||||
<div class="card-body">
|
||||
<table class="table text-center">
|
||||
<thead class="thead-dark">
|
||||
<tr>
|
||||
<th scope="col">Titre</th>
|
||||
<th scope="col">Publié ?</th>
|
||||
<th scope="col"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($m as $moment)
|
||||
<tr>
|
||||
<th>{{$moment->title}}</th>
|
||||
<td>
|
||||
@if ($moment->status === 1)
|
||||
Oui
|
||||
@else
|
||||
Non
|
||||
@endif
|
||||
</td>
|
||||
<td><a href="{{route('bo.moments.edit', $moment->id)}}" class="btn btn-sm btn-primary">Éditer</a></td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
<!-- Styles -->
|
||||
<link href="{{ asset('css/app.css') }}" rel="stylesheet">
|
||||
@yield('styles')
|
||||
</head>
|
||||
<body>
|
||||
<div id="app">
|
||||
|
|
@ -152,7 +153,13 @@
|
|||
<a class="dropdown-item" href="{{route('bo.articles.create')}}">Ajouter</a>
|
||||
</div>
|
||||
</li>
|
||||
<a class="nav-link" href="#">En ce moment</a>
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button">En ce moment</a>
|
||||
<div class="dropdown-menu">
|
||||
<a class="dropdown-item" href="{{route('bo.moments.index')}}">Tous les moments</a>
|
||||
<a class="dropdown-item" href="{{route('bo.moments.create')}}">Ajouter</a>
|
||||
</div>
|
||||
</li>
|
||||
<a class="nav-link" href="#">Les réductions</a>
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button">Les QR codes</a>
|
||||
|
|
|
|||
|
|
@ -45,11 +45,12 @@ Route::namespace('Bo')
|
|||
Route::get('/faq-themes/change-order/{id}/{action}', 'FaqThemesController@changeOrder')->name('faq-themes.change-order');
|
||||
Route::resource('faq-questions', 'FaqQuestionsController');
|
||||
Route::resource('balanced-menus', 'BalancedMenusController');
|
||||
Route::get('/ocb/index/{type}', 'ContentOCBController@index')->name('ocb.content');
|
||||
Route::get('/ocb/content/{type}', 'ContentOCBController@index')->name('ocb.content');
|
||||
Route::resource('ocb', 'ContentOCBController');
|
||||
Route::get('/ocb/change-order/{id}/{type}/{action}', 'ContentOCBController@changeOrder')->name('ocb.change-order');
|
||||
Route::get('/breeders/index/{type}', 'BreedersController@index')->name('breeders.content');
|
||||
Route::get('/breeders/content/{type}', 'BreedersController@index')->name('breeders.content');
|
||||
Route::resource('breeders', 'BreedersController');
|
||||
Route::resource('moments', 'MomentsController');
|
||||
});
|
||||
|
||||
Route::get('/', function () {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue