mirror of
https://gitlab.com/TheGamecraft/c-cms.git
synced 2026-04-21 02:39:10 -04:00
Update Picture to S3
This commit is contained in:
@@ -43,12 +43,18 @@ class PictureController extends Controller
|
|||||||
$pic = new Picture();
|
$pic = new Picture();
|
||||||
|
|
||||||
$pic->title = request('title');
|
$pic->title = request('title');
|
||||||
$pic->url = request('url');
|
$pic->url = "";
|
||||||
$pic->desc = request('desc');
|
$pic->desc = request('desc');
|
||||||
$pic->pictureable_id = 0;
|
$pic->pictureable_id = 0;
|
||||||
$pic->pictureable_type = "";
|
$pic->pictureable_type = "";
|
||||||
|
|
||||||
$pic->save();
|
$pic->save();
|
||||||
|
|
||||||
|
$filename = $pic->title.'-'.$pic->id.'.'.\request()->file('file')->getClientOriginalExtension();
|
||||||
|
\Storage::putFileAs('Publique/Image',\request()->file('file'),$filename);
|
||||||
|
|
||||||
|
$pic->url = '/api/files/Publique/Image/'.$filename;
|
||||||
|
$pic->save();
|
||||||
|
|
||||||
clog('add','success','a ajouté une image',null,'App\Picture',$pic->id);
|
clog('add','success','a ajouté une image',null,'App\Picture',$pic->id);
|
||||||
return redirect('/admin/picture')->with('success','Image ajoutée avec succès');
|
return redirect('/admin/picture')->with('success','Image ajoutée avec succès');
|
||||||
|
|
||||||
@@ -87,9 +93,15 @@ class PictureController extends Controller
|
|||||||
public function update($id)
|
public function update($id)
|
||||||
{
|
{
|
||||||
$pic = Picture::find($id);
|
$pic = Picture::find($id);
|
||||||
|
if (\request()->hasFile('file'))
|
||||||
|
{
|
||||||
|
\Storage::delete(str_replace('/api/files/','',$pic->url));
|
||||||
|
$filename = \request('title').'-'.$pic->id.'.'.\request()->file('file')->getClientOriginalExtension();
|
||||||
|
\Storage::putFileAs('Publique/Image',\request()->file('file'),$filename);
|
||||||
|
|
||||||
|
$pic->url = '/api/files/Publique/Image/'.$filename;
|
||||||
|
}
|
||||||
$pic->title = request('title');
|
$pic->title = request('title');
|
||||||
$pic->url = request('url');
|
|
||||||
$pic->desc = request('desc');
|
$pic->desc = request('desc');
|
||||||
|
|
||||||
$pic->save();
|
$pic->save();
|
||||||
@@ -113,7 +125,7 @@ class PictureController extends Controller
|
|||||||
public function destroy($id)
|
public function destroy($id)
|
||||||
{
|
{
|
||||||
$pic = Picture::find($id);
|
$pic = Picture::find($id);
|
||||||
|
\Storage::delete(str_replace('/api/files/','',$pic->url));
|
||||||
$pic->delete();
|
$pic->delete();
|
||||||
clog('delete','success','a supprimé une image',null,'App\Picture',$id);
|
clog('delete','success','a supprimé une image',null,'App\Picture',$id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,26 +7,31 @@
|
|||||||
<h4>Ajouter une images</h4>
|
<h4>Ajouter une images</h4>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body mt-5">
|
<div class="card-body mt-5">
|
||||||
<form action="/admin/picture/add" method="post">
|
<form action="/admin/picture/add" method="post" enctype="multipart/form-data">
|
||||||
|
|
||||||
@csrf
|
@csrf
|
||||||
|
|
||||||
<div class="col-lg-12">
|
<div class="col-lg-12">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>Nom de l'image</label>
|
<label>Nom de l'image</label>
|
||||||
<input name="title" type="text" class="form-control">
|
<input name="title" type="text" class="form-control" required>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-lg-12">
|
<div class="col-lg-12">
|
||||||
<div class="form-group">
|
<div class="form-group bmd-form-group is-filled">
|
||||||
<label>URL de l'image</label>
|
<label class="label-control bmd-label-static">Choisir l'image</label>
|
||||||
<input name="url" type="text" class="form-control">
|
<div class="fileinput fileinput-new input-group" data-provides="fileinput" style="display: flex !important;">
|
||||||
|
<div class="form-control" data-trigger="fileinput">
|
||||||
|
<span class="fileinput-filename"></span>
|
||||||
|
</div>
|
||||||
|
<span class="input-group-append"><span class="input-group-text fileinput-exists cursor" data-dismiss="fileinput">Remove</span><span class="input-group-text btn-file"><span class="fileinput-new cursor">Select file</span><span class="fileinput-exists cursor">Change</span><input type="file" name="file" required accept="image/*"></span></span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-lg-12">
|
<div class="col-lg-12">
|
||||||
<label for="desc">Description de l'image</label>
|
<label for="desc">Description de l'image</label>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<textarea name="desc" id="desc" class="form-control"></textarea>
|
<textarea name="desc" id="desc" class="form-control" required></textarea>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-lg-12">
|
<div class="col-lg-12">
|
||||||
@@ -44,20 +49,5 @@
|
|||||||
$('#desc').trumbowyg({
|
$('#desc').trumbowyg({
|
||||||
lang: 'fr'
|
lang: 'fr'
|
||||||
});
|
});
|
||||||
function saveChange(pPerm) {
|
|
||||||
(function($) {
|
|
||||||
var myswitch = document.getElementById(pPerm);
|
|
||||||
$.post('/api/config/general/save?api_token='+api_token, { value: myswitch.checked,perm: pPerm } , function(data) {
|
|
||||||
swal({
|
|
||||||
title: 'Modification enregistré !',
|
|
||||||
type: 'success',
|
|
||||||
}).then((result) => {
|
|
||||||
if (result.value) {
|
|
||||||
location.reload();
|
|
||||||
}
|
|
||||||
})
|
|
||||||
});
|
|
||||||
})(jQuery);
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
@endsection
|
@endsection
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
<h4>Ajouter une images</h4>
|
<h4>Ajouter une images</h4>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body mt-5">
|
<div class="card-body mt-5">
|
||||||
<form action="/admin/picture/edit/{{$picture->id}}" method="post">
|
<form action="/admin/picture/edit/{{$picture->id}}" method="post" enctype="multipart/form-data">
|
||||||
|
|
||||||
@csrf
|
@csrf
|
||||||
|
|
||||||
@@ -18,9 +18,14 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-lg-12">
|
<div class="col-lg-12">
|
||||||
<div class="form-group">
|
<div class="form-group bmd-form-group is-filled">
|
||||||
<label>URL de l'image</label>
|
<label class="label-control bmd-label-static">Choisir l'image</label>
|
||||||
<input name="url" type="text" class="form-control" value="{{$picture->url}}">
|
<div class="fileinput fileinput-new input-group" data-provides="fileinput" style="display: flex !important;">
|
||||||
|
<div class="form-control" data-trigger="fileinput">
|
||||||
|
<span class="fileinput-filename"></span>
|
||||||
|
</div>
|
||||||
|
<span class="input-group-append"><span class="input-group-text fileinput-exists cursor" data-dismiss="fileinput">Remove</span><span class="input-group-text btn-file"><span class="fileinput-new cursor">Select file</span><span class="fileinput-exists cursor">Change</span><input type="file" name="file" accept="image/*"></span></span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-lg-12">
|
<div class="col-lg-12">
|
||||||
|
|||||||
@@ -31,13 +31,13 @@
|
|||||||
<button class="btn btn-danger" onclick="Delete({{$picture->id}})"><i class="fas fa-times"></i></button>
|
<button class="btn btn-danger" onclick="Delete({{$picture->id}})"><i class="fas fa-times"></i></button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@if($picture->pictureable)
|
{{-- @if($picture->pictureable)
|
||||||
<div class="col-xl-5 m-auto text-right">
|
<div class="col-xl-5 m-auto text-right">
|
||||||
<a href="/activity/{{$picture->pictureable->id}}" target="_blank">
|
<a href="/activity/{{$picture->pictureable->id}}" target="_blank">
|
||||||
<span class="badge badge-primary">{{$picture->pictureable->name}}</span>
|
<span class="badge badge-primary">{{$picture->pictureable->name}}</span>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif--}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -60,12 +60,6 @@
|
|||||||
// 'perm' => 'article_see',
|
// 'perm' => 'article_see',
|
||||||
// 'child' => null
|
// 'child' => null
|
||||||
//],
|
//],
|
||||||
//'Images' => [
|
|
||||||
// 'route' => 'admin.picture',
|
|
||||||
// 'icon' => 'fas fa-images',
|
|
||||||
// 'perm' => 'picture_see',
|
|
||||||
// 'child' => null
|
|
||||||
//],
|
|
||||||
'Utilisateurs' => [
|
'Utilisateurs' => [
|
||||||
'route' => 'admin.users',
|
'route' => 'admin.users',
|
||||||
'icon' => 'fas fa-users',
|
'icon' => 'fas fa-users',
|
||||||
@@ -78,6 +72,12 @@
|
|||||||
'perm' => 'cadet_list_see',
|
'perm' => 'cadet_list_see',
|
||||||
'child' => null
|
'child' => null
|
||||||
],
|
],
|
||||||
|
'Images' => [
|
||||||
|
'route' => 'admin.picture',
|
||||||
|
'icon' => 'fas fa-images',
|
||||||
|
'perm' => 'picture_see',
|
||||||
|
'child' => null
|
||||||
|
],
|
||||||
'Logs' => [
|
'Logs' => [
|
||||||
'route' => 'admin.stats.log',
|
'route' => 'admin.stats.log',
|
||||||
'icon' => 'fas fa-stream',
|
'icon' => 'fas fa-stream',
|
||||||
|
|||||||
Reference in New Issue
Block a user