bo magasin (basic)
This commit is contained in:
parent
2b6b9bcaae
commit
286a0fab2a
9 changed files with 359 additions and 6 deletions
|
|
@ -3,9 +3,113 @@
|
|||
namespace App\Http\Controllers\Bo;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Magasin;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class MagasinsController extends Controller
|
||||
{
|
||||
//
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$magasins = Magasin::all();
|
||||
return view('bo.magasins.index', compact('magasins'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return view('bo.magasins.create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'name' => 'required|string|max:255',
|
||||
'address' => 'required|string|max:255',
|
||||
'postcode' => 'required',
|
||||
'city' => 'required|string|max:255',
|
||||
]);
|
||||
|
||||
$shop = Magasin::create($request->except('_token'));
|
||||
return redirect()->route('bo.magasins.edit', $shop->id)->with('success', 'Nouveau Magasin enregistré !');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$magasin = Magasin::findOrFail($id);
|
||||
return view('bo.magasins.edit', compact('magasin'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
$request->validate([
|
||||
'name' => 'required|string|max:255',
|
||||
'address' => 'required|string|max:255',
|
||||
'postcode' => 'required',
|
||||
'city' => 'required|string|max:255',
|
||||
]);
|
||||
|
||||
$shop = Magasin::findOrFail($id);
|
||||
$shop->fill($request->except('_token'))->save();
|
||||
return redirect()->route('bo.magasins.edit', $shop->id)->with('success', 'Modifications enregistrés !');
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
$shop = Magasin::findOrFail($id);
|
||||
|
||||
$count = Magasin::count();
|
||||
|
||||
if ($count === 1) {
|
||||
return redirect()->back()->withErrors("Suppression impossible : Vous devez conserver au moins 1 point de retrait.");
|
||||
}
|
||||
// @todo : controller les crenaux settings liés
|
||||
|
||||
$shop->delete();
|
||||
return redirect()->route('bo.magasins.index');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -113,12 +113,14 @@ class RangesController extends Controller
|
|||
$range = Range::findOrFail($id);
|
||||
|
||||
$product = Product::where('range_id', $range->id)->count();
|
||||
if ($product !== 0)
|
||||
if ($product !== 0) {
|
||||
return redirect()->back()->withErrors("Suppression impossible : \"" . $range->name . "\" contient encore des produits.");
|
||||
}
|
||||
|
||||
if($range->picture !== null) {
|
||||
if (file_exists(public_path('images/gammes/') . $range->picture))
|
||||
if ($range->picture !== null) {
|
||||
if (file_exists(public_path('images/gammes/') . $range->picture)) {
|
||||
unlink(public_path('images/gammes/') . $range->picture);
|
||||
}
|
||||
}
|
||||
|
||||
OldSlug::where('range_id', $range->id)->delete();
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ use App\Http\Requests\ContactFormRequest;
|
|||
use App\Mail\SendContactMail;
|
||||
use App\Models\Magasin;
|
||||
use App\Models\Setting;
|
||||
use App\Models\Content;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
|
|
@ -17,8 +18,9 @@ class ContactController extends Controller
|
|||
|
||||
//1 seul magasin en base pour le moment
|
||||
$magasin = Magasin::first();
|
||||
$content = Content::where('key', 'contact')->first();
|
||||
|
||||
return view('contact', compact('status', 'magasin'));
|
||||
return view('contact', compact('status', 'magasin', 'content'));
|
||||
}
|
||||
|
||||
public function contactSubmit(ContactFormRequest $request)
|
||||
|
|
|
|||
|
|
@ -8,4 +8,10 @@ use Illuminate\Database\Eloquent\Model;
|
|||
class Magasin extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'name', 'address', 'postcode', 'city', 'phone',
|
||||
'latitude', 'longitude',
|
||||
'gmaps_placeid', 'gmaps_embed_href', 'gmaps_link_href',
|
||||
];
|
||||
}
|
||||
|
|
|
|||
95
resources/views/bo/magasins/create.blade.php
Normal file
95
resources/views/bo/magasins/create.blade.php
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
@extends('layouts.bo-layout')
|
||||
|
||||
@section('content')
|
||||
<form action="{{route('bo.magasins.store')}}" method="POST" enctype="multipart/form-data">
|
||||
@csrf
|
||||
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
|
||||
<h1 class="h2"><a href="{{route('bo.magasins.index')}}" class="h2 text-decoration-none"><</a> Magasin <small class="text-muted">Création</small></h1>
|
||||
<div class="btn-toolbar mb-2 mb-md-0">
|
||||
<button type="submit" class="btn btn-sm btn-primary">Enregistrer</a>
|
||||
</div>
|
||||
</div>
|
||||
@if ($errors->any())
|
||||
<div class="alert alert-danger">
|
||||
<ul>
|
||||
@foreach ($errors->all() as $error)
|
||||
<li>{{ $error }}</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
</div>
|
||||
@endif
|
||||
<div class="form-group">
|
||||
<label for="name">Nom *</label>
|
||||
<input type="text" id="name" name="name" class="form-control" placeholder="Nom *" value="{{ old('name') }}" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Adresse *</label>
|
||||
<input type="text" id="address" name="address" class="form-control" placeholder="Adresse *" value="{{ old('address') }}" required>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col">
|
||||
<label>Code postal *</label>
|
||||
<input type="text" id="postcode" name="postcode" class="form-control" placeholder="Code postal *" value="{{ old('postcode') }}" required>
|
||||
</div>
|
||||
<div class="form-group col">
|
||||
<label>Ville *</label>
|
||||
<input type="text" id="city" name="city" class="form-control" placeholder="Ville *" value="{{ old('city') }}" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Téléphone</label>
|
||||
<input type="text" id="phone" name="phone" class="form-control" placeholder="Téléphone" value="{{ old('phone') }}">
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col">
|
||||
<label>Latitude</label>
|
||||
<input type="text" id="latitude" name="latitude" class="form-control" placeholder="Latitude" value="{{ old('latitude') }}">
|
||||
</div>
|
||||
<div class="form-group col">
|
||||
<label>Longitude</label>
|
||||
<input type="text" id="longitude" name="longitude" class="form-control" placeholder="Longitude" value="{{ old('longitude') }}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
|
||||
<h2><small class="text-muted">Google Maps</small></h2>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Embed href</label>
|
||||
<input type="text" id="gmaps_embed_href" name="gmaps_embed_href" class="form-control" placeholder="url cible pour les iframes" value="{{ old('gmaps_embed_href') }}">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Lien direct</label>
|
||||
<input type="text" id="gmaps_link_href" name="gmaps_link_href" class="form-control" placeholder="url vers google maps" value="{{ old('gmaps_link_href') }}">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>placeID</label>
|
||||
<input type="text" id="gmaps_placeid" name="gmaps_placeid" class="form-control" placeholder="placeID google maps (necessite une clé d'API)" value="{{ old('gmaps_placeid') }}">
|
||||
</div>
|
||||
</form>
|
||||
@endsection
|
||||
|
||||
@section('scripts')
|
||||
<script type="text/javascript">
|
||||
var editorConfig = {
|
||||
removePlugins: ["Image", "ImageCaption", "ImageStyle", "ImageToolbar", "ImageUpload"],
|
||||
toolbar: [ 'heading', '|', 'bold', 'italic', 'link', 'bulletedList', 'numberedList', '|', 'blockQuote', 'insertTable', '|', 'undo', 'redo' ],
|
||||
heading: {
|
||||
options: [
|
||||
{ model: 'paragraph', title: 'Paragraph', class: 'ck-heading_paragraph' },
|
||||
{ model: 'heading1', view: 'h1', title: 'Heading 1', class: 'ck-heading_heading1' },
|
||||
{ model: 'heading2', view: 'h2', title: 'Heading 2', class: 'ck-heading_heading2' },
|
||||
{ model: 'heading3', view: 'h3', title: 'Heading 3', class: 'ck-heading_heading3' },
|
||||
{ model: 'heading4', view: 'h4', title: 'Heading 4', class: 'ck-heading_heading4' }
|
||||
]
|
||||
},
|
||||
table: {
|
||||
contentToolbar: [ 'tableColumn', 'tableRow', 'mergeTableCells' ]
|
||||
}
|
||||
};
|
||||
ClassicEditor
|
||||
.create( document.querySelector( '#description' ), editorConfig)
|
||||
.catch( error => {
|
||||
console.error( error );
|
||||
} );
|
||||
</script>
|
||||
@endsection
|
||||
77
resources/views/bo/magasins/edit.blade.php
Normal file
77
resources/views/bo/magasins/edit.blade.php
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
@extends('layouts.bo-layout')
|
||||
|
||||
@section('content')
|
||||
<form action="{{route('bo.magasins.update', $magasin->id)}}" method="POST" enctype="multipart/form-data">
|
||||
@method('PUT')
|
||||
@csrf
|
||||
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
|
||||
<h1 class="h2"><a href="{{route('bo.magasins.index')}}" class="h2 text-decoration-none"><</a> Magasin <small class="text-muted">Modification</small></h1>
|
||||
@if (session('success'))
|
||||
<span class="float-center text-success">{{ session('success') }}</span>
|
||||
@endif
|
||||
<div class="btn-toolbar mb-2 mb-md-0">
|
||||
<button type="submit" class="btn btn-sm btn-primary">Enregistrer</a>
|
||||
</div>
|
||||
</div>
|
||||
@if ($errors->any())
|
||||
<div class="alert alert-danger">
|
||||
<ul>
|
||||
@foreach ($errors->all() as $error)
|
||||
<li>{{ $error }}</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
</div>
|
||||
@endif
|
||||
<div class="form-group">
|
||||
<label for="name">Nom *</label>
|
||||
<input type="text" id="name" name="name" class="form-control" placeholder="Nom *" value="{{ old('name',$magasin->name) }}" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Adresse *</label>
|
||||
<input type="text" id="address" name="address" class="form-control" placeholder="Adresse *" value="{{ old('address',$magasin->address) }}" required>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col">
|
||||
<label>Code postal *</label>
|
||||
<input type="text" id="postcode" name="postcode" class="form-control" placeholder="Code postal *" value="{{ old('postcode',$magasin->postcode) }}" required>
|
||||
</div>
|
||||
<div class="form-group col">
|
||||
<label>Ville *</label>
|
||||
<input type="text" id="city" name="city" class="form-control" placeholder="Ville *" value="{{ old('city',$magasin->city) }}" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Téléphone</label>
|
||||
<input type="text" id="phone" name="phone" class="form-control" placeholder="Téléphone" value="{{ old('phone',$magasin->phone) }}">
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col">
|
||||
<label>Latitude</label>
|
||||
<input type="text" id="latitude" name="latitude" class="form-control" placeholder="Latitude" value="{{ old('latitude',$magasin->latitude) }}">
|
||||
</div>
|
||||
<div class="form-group col">
|
||||
<label>Longitude</label>
|
||||
<input type="text" id="longitude" name="longitude" class="form-control" placeholder="Longitude" value="{{ old('longitude',$magasin->longitude) }}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
|
||||
<h2><small class="text-muted">Google Maps</small></h2>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Embed href</label>
|
||||
<input type="text" id="gmaps_embed_href" name="gmaps_embed_href" class="form-control" placeholder="url cible pour les iframes" value="{{ old('gmaps_embed_href',$magasin->gmaps_embed_href) }}">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Lien direct</label>
|
||||
<input type="text" id="gmaps_link_href" name="gmaps_link_href" class="form-control" placeholder="url vers google maps" value="{{ old('gmaps_link_href',$magasin->gmaps_link_href) }}">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>placeID</label>
|
||||
<input type="text" id="gmaps_placeid" name="gmaps_placeid" class="form-control" placeholder="placeID google maps (necessite une clé d'API)" value="{{ old('gmaps_placeid',$magasin->gmaps_placeid) }}">
|
||||
</div>
|
||||
</form>
|
||||
@endsection
|
||||
|
||||
@section('scripts')
|
||||
|
||||
@endsection
|
||||
44
resources/views/bo/magasins/index.blade.php
Normal file
44
resources/views/bo/magasins/index.blade.php
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
@extends('layouts.bo-layout')
|
||||
|
||||
@section('content')
|
||||
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
|
||||
<h1 class="h2">Points de retrait <small class="text-muted">Liste</small></h1>
|
||||
<!-- TODO : Tester quand il y aura des produits la suppression d'une gamme qui en a -->
|
||||
@if ($errors->any())
|
||||
@foreach($errors->all() as $error)
|
||||
<span class="float-center text-danger">{{ $error }}</span>
|
||||
@endforeach
|
||||
@endif
|
||||
<a href="{{route('bo.magasins.create')}}" class="btn btn-primary float-right">Ajouter</a>
|
||||
</div>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<th scope="col"></th>
|
||||
<th scope="col">Nom</th>
|
||||
<th scope="col">Adresse</th>
|
||||
<th scope="col">Téléphone</th>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($magasins as $magasin)
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>{{$magasin->name}}</td>
|
||||
<td>{{$magasin->address}}, {{$magasin->postcode}} {{$magasin->city}}</td>
|
||||
<td>{{$magasin->phone}}</td>
|
||||
<td class="text-center">
|
||||
<a href="{{route('bo.magasins.edit', $magasin->id)}}" class="btn btn-sm btn-primary">Éditer</a>
|
||||
<form action="{{route('bo.magasins.destroy', $magasin->id)}}" method="POST" class="d-inline">
|
||||
@method('DELETE')
|
||||
@csrf
|
||||
<input type="submit" class="btn btn-sm btn-danger" value="Supprimer"
|
||||
onclick="return confirm('Êtes-vous sûr(e) ?')">
|
||||
</form>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
@endsection
|
||||
|
||||
|
||||
|
|
@ -110,7 +110,7 @@
|
|||
<div class="card-header" id="headingProduits">
|
||||
<h2 class="mb-0">
|
||||
<button class="btn btn-link btn-block text-left" type="button" data-toggle="collapse" data-target="#collapseProduits" aria-expanded="true" aria-controls="collapseOne">
|
||||
<i class="fas fa-store"></i> Produits
|
||||
<i class="fas fa-warehouse"></i> Catalogue
|
||||
</button>
|
||||
</h2>
|
||||
</div>
|
||||
|
|
@ -167,6 +167,26 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Points de Collecte -->
|
||||
<div class="card">
|
||||
<div class="card-header" id="headingCollecte">
|
||||
<h2 class="mb-0">
|
||||
<button class="btn btn-link btn-block text-left" type="button" data-toggle="collapse" data-target="#collapseCollecte" aria-expanded="true" aria-controls="collapseOne">
|
||||
<i class="fas fa-store"></i> Points de retrait
|
||||
</button>
|
||||
</h2>
|
||||
</div>
|
||||
|
||||
<div id="collapseCollecte" class="collapse {{ ( request()->routeIs('bo.magasins*') ) ? 'show' : '' }}" aria-labelledby="headingCollecte" tata-parent="#accordionMenu">
|
||||
<div class="card-body">
|
||||
<ul class="nav flex-column mb-2">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{{route('bo.magasins.index')}}">Magasins</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<div class="card-header" id="headingSettings">
|
||||
<h2 class="mb-0">
|
||||
|
|
|
|||
|
|
@ -16,9 +16,11 @@ use App\Http\Controllers\Bo\SettingsController;
|
|||
use App\Http\Controllers\Bo\OrdersController;
|
||||
use App\Http\Controllers\Bo\CreneauxController;
|
||||
//use App\Http\Controllers\Bo\RangesController;
|
||||
//use App\Http\Controllers\Bo\MagasinsController;
|
||||
// AUTH
|
||||
use App\Http\Controllers\Auth\LoginController;
|
||||
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Web Routes
|
||||
|
|
@ -98,6 +100,7 @@ Route::namespace('App\Http\Controllers\Bo')
|
|||
'promotions' => PromotionsController::class,
|
||||
'sliders' => SlidersController::class,
|
||||
'slides' => SlidesController::class,
|
||||
'magasins' => MagasinsController::class,
|
||||
]);
|
||||
Route::get('/slide/change-order/{id}/{action}', [App\Http\Controllers\Bo\SlidesController::class,'changeOrder'])->name('slides.change-order');
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue