|
@@ -1,6 +1,7 @@
|
|
|
<?php
|
|
|
|
|
|
namespace App\Http\Controllers\backend;
|
|
|
+
|
|
|
use App\Http\Controllers\Controller;
|
|
|
use Illuminate\Http\Request;
|
|
|
use App\Models\Produit;
|
|
@@ -18,375 +19,410 @@ use Illuminate\Support\Facades\Storage;
|
|
|
|
|
|
class ProduitController extends Controller
|
|
|
{
|
|
|
- public function __construct(){
|
|
|
- return $this->middleware(['auth','verified']);
|
|
|
-
|
|
|
+ public function __construct()
|
|
|
+ {
|
|
|
+ return $this->middleware(['auth', 'verified']);
|
|
|
}
|
|
|
|
|
|
- public function Index(){
|
|
|
+ public function Index()
|
|
|
+ {
|
|
|
|
|
|
$articles = Produit::paginate(5);
|
|
|
|
|
|
- return view("backend.produit.index",compact('articles'));
|
|
|
- }
|
|
|
+ return view("backend.produit.index", compact('articles'));
|
|
|
+ }
|
|
|
+
|
|
|
+ public function create()
|
|
|
+ {
|
|
|
|
|
|
- public function create(){
|
|
|
-
|
|
|
$categories = Categorie::select('nom', 'id')->oldest('nom')->get();
|
|
|
-
|
|
|
|
|
|
- return view('backend.produit.add',compact('categories'));
|
|
|
|
|
|
- }
|
|
|
- public function store( Request $request){
|
|
|
+ return view('backend.produit.add', compact('categories'));
|
|
|
+ }
|
|
|
+ public function store(Request $request)
|
|
|
+ {
|
|
|
request()->validate([
|
|
|
'nom' => 'required',
|
|
|
'description' => 'required',
|
|
|
-
|
|
|
+
|
|
|
'description' => 'required',
|
|
|
- 'image'=> 'required'
|
|
|
- ]);
|
|
|
- $tmp_file = temporaryFile::where('folder',$request->image)->first();
|
|
|
-
|
|
|
-
|
|
|
- if($tmp_file){
|
|
|
- Storage::copy('image/tmp/'.$tmp_file->folder.'/'.$tmp_file->file,'image/'.$tmp_file->folder.'/'.$tmp_file->file);
|
|
|
-
|
|
|
- $article = Produit::create(
|
|
|
- [
|
|
|
- 'nom' => $request->nom,
|
|
|
- // 'category_id' => $request->input('categorie'),
|
|
|
- 'description' => $request->description,
|
|
|
- 'image' => $tmp_file->folder . '/' . $tmp_file->file,
|
|
|
- ],
|
|
|
- );
|
|
|
-
|
|
|
- $article->categories()->sync((array)$request->input('categories'));
|
|
|
-
|
|
|
- Storage::deleteDirectory('diapo/tmp/'.$tmp_file->folder);
|
|
|
- $tmp_file->delete();
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- return redirect()->route('produits');
|
|
|
-
|
|
|
+ 'image' => 'required'
|
|
|
+ ]);
|
|
|
+ $tmp_file = temporaryFile::where('folder', $request->image)->first();
|
|
|
+
|
|
|
+
|
|
|
+ if ($tmp_file) {
|
|
|
+ Storage::copy('image/tmp/' . $tmp_file->folder . '/' . $tmp_file->file, 'image/' . $tmp_file->folder . '/' . $tmp_file->file);
|
|
|
+
|
|
|
+ if ($request->filled('titre_seo')) {
|
|
|
+ $article = Produit::create(
|
|
|
+ [
|
|
|
+ 'nom' => $request->nom,
|
|
|
+ // 'category_id' => $request->input('categorie'),
|
|
|
+ 'description' => $request->description,
|
|
|
+ 'titre_seo' => $request->titre_seo,
|
|
|
+ 'resume_seo' => $request->resume_seo,
|
|
|
+ 'mot_cle' => $request->mot_cle,
|
|
|
+
|
|
|
+ 'image' => $tmp_file->folder . '/' . $tmp_file->file,
|
|
|
+ ],
|
|
|
+ );
|
|
|
+ }else{
|
|
|
+ $article = Produit::create(
|
|
|
+ [
|
|
|
+ 'nom' => $request->nom,
|
|
|
+ // 'category_id' => $request->input('categorie'),
|
|
|
+ 'description' => $request->description,
|
|
|
+ 'titre_seo' => $request->nom,
|
|
|
+ 'resume_seo' => strip_tags( $request->description),
|
|
|
+ 'mot_cle' => $request->mot_cle,
|
|
|
+
|
|
|
+ 'image' => $tmp_file->folder . '/' . $tmp_file->file,
|
|
|
+ ],
|
|
|
+ );
|
|
|
+ }
|
|
|
+ $article->categories()->sync((array)$request->input('categories'));
|
|
|
+
|
|
|
+ Storage::deleteDirectory('diapo/tmp/' . $tmp_file->folder);
|
|
|
+ $tmp_file->delete();
|
|
|
+ }
|
|
|
+ return redirect()->route('produits');
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- public function show($id){
|
|
|
-
|
|
|
|
|
|
- $article=Produit::find($id);
|
|
|
- $diapos=Media::where('produit_id','=',$article->id)->get();
|
|
|
-
|
|
|
+ public function show($id)
|
|
|
+ {
|
|
|
+
|
|
|
+
|
|
|
+ $article = Produit::find($id);
|
|
|
+ $diapos = Media::where('produit_id', '=', $article->id)->get();
|
|
|
+
|
|
|
if ($article->document != null) {
|
|
|
-
|
|
|
|
|
|
- $size = Storage::size('document/'.$article->document);
|
|
|
- $file_size = $size * 0.0009765625;
|
|
|
- $sizeFile = number_format($file_size,0);
|
|
|
-
|
|
|
- $infoPath = pathinfo(public_path('document/'.$article->document));
|
|
|
+
|
|
|
+ $size = Storage::size('document/' . $article->document);
|
|
|
+ $file_size = $size * 0.0009765625;
|
|
|
+ $sizeFile = number_format($file_size, 0);
|
|
|
+
|
|
|
+ $infoPath = pathinfo(public_path('document/' . $article->document));
|
|
|
$extension = $infoPath['extension'];
|
|
|
-
|
|
|
- return view('backend.produit.show',compact('article','diapos','extension','sizeFile'));
|
|
|
+
|
|
|
+ return view('backend.produit.show', compact('article', 'diapos', 'extension', 'sizeFile'));
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
|
|
|
- return view('backend.produit.show',compact('article','diapos'));
|
|
|
|
|
|
+
|
|
|
+ return view('backend.produit.show', compact('article', 'diapos'));
|
|
|
}
|
|
|
|
|
|
-
|
|
|
|
|
|
-
|
|
|
- public function edit($id) {
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+ public function edit($id)
|
|
|
+ {
|
|
|
+
|
|
|
$article = Produit::find($id);
|
|
|
$categories = Categorie::select('nom', 'id')->oldest('nom')->get();
|
|
|
-
|
|
|
-
|
|
|
- return view('backend.produit.edit',['article'=>$article],compact('categories'));
|
|
|
|
|
|
+
|
|
|
+ return view('backend.produit.edit', ['article' => $article], compact('categories'));
|
|
|
}
|
|
|
- public function update(Request $request, $id) {
|
|
|
+ public function update(Request $request, $id)
|
|
|
+ {
|
|
|
request()->validate([
|
|
|
'nom' => 'required',
|
|
|
- 'description' => 'required',
|
|
|
- 'categories'=> 'required',
|
|
|
-
|
|
|
+ 'description' => 'required',
|
|
|
+ 'categories' => 'required',
|
|
|
+
|
|
|
+
|
|
|
|
|
|
-
|
|
|
- ]);
|
|
|
+ ]);
|
|
|
$article = Produit::find($id);
|
|
|
$article->nom = $request->input('nom');
|
|
|
-
|
|
|
+
|
|
|
|
|
|
$article->description = $request->input('description');
|
|
|
+ if ($request->filled('titre_seo')) {
|
|
|
+ $article->titre_seo = $request->input('titre_seo');
|
|
|
+
|
|
|
+ }else{
|
|
|
+ $article->titre_seo = $request->input('titre');
|
|
|
+
|
|
|
+ }
|
|
|
+ if ($request->filled('resume_seo')) {
|
|
|
+ $article->resume_seo = $request->input('resume_seo');
|
|
|
+
|
|
|
+ }else{
|
|
|
+ $article->resume_seo = strip_tags( $request->input('description'));
|
|
|
+
|
|
|
+ }
|
|
|
+ $article->mot_cle = $request->input('mot_cle');
|
|
|
+
|
|
|
|
|
|
$article->categories()->sync((array)$request->input('categories'));
|
|
|
|
|
|
|
|
|
- $tmp_file = temporaryFile::where('folder',$request->image)->first();
|
|
|
+ $tmp_file = temporaryFile::where('folder', $request->image)->first();
|
|
|
+
|
|
|
+ if ($tmp_file) {
|
|
|
+ Storage::copy('image/tmp/' . $tmp_file->folder . '/' . $tmp_file->file, 'image/' . $tmp_file->folder . '/' . $tmp_file->file);
|
|
|
|
|
|
- if($tmp_file){
|
|
|
- Storage::copy('image/tmp/'.$tmp_file->folder.'/'.$tmp_file->file,'image/'.$tmp_file->folder.'/'.$tmp_file->file);
|
|
|
-
|
|
|
$article->update([
|
|
|
-
|
|
|
+
|
|
|
"image" => $tmp_file->folder . '/' . $tmp_file->file
|
|
|
]);
|
|
|
- Storage::deleteDirectory('diapo/tmp/'.$tmp_file->folder);
|
|
|
- $tmp_file->delete();
|
|
|
- }
|
|
|
- $article->created_at = \Carbon\Carbon::now();
|
|
|
+ Storage::deleteDirectory('diapo/tmp/' . $tmp_file->folder);
|
|
|
+ $tmp_file->delete();
|
|
|
+ }
|
|
|
+ $article->created_at = \Carbon\Carbon::now();
|
|
|
$article->save();
|
|
|
- return redirect ()->route('produits')->with('success','Modifié');
|
|
|
+ return redirect()->route('produits')->with('success', 'Modifié');
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- public function diapo($id) {
|
|
|
+
|
|
|
+ public function diapo($id)
|
|
|
+ {
|
|
|
$article = Produit::find($id);
|
|
|
- return view('backend.produit.extension.diapo',['article'=>$article]);
|
|
|
- }
|
|
|
+ return view('backend.produit.extension.diapo', ['article' => $article]);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function updateDiapo(Request $request, $id)
|
|
|
+ {
|
|
|
|
|
|
- public function updateDiapo(Request $request, $id) {
|
|
|
-
|
|
|
request()->validate([
|
|
|
-
|
|
|
- 'diapo'=> 'required',
|
|
|
-
|
|
|
-
|
|
|
- ]);
|
|
|
-
|
|
|
- $tmp_file = temporaryFile::where('folder',$request->diapo)->first();
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+ 'diapo' => 'required',
|
|
|
+
|
|
|
+
|
|
|
+ ]);
|
|
|
+
|
|
|
+ $tmp_file = temporaryFile::where('folder', $request->diapo)->first();
|
|
|
+
|
|
|
+
|
|
|
$article = Produit::find($id);
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- if($tmp_file){
|
|
|
-
|
|
|
- Storage::copy('diapo/tmp/'.$tmp_file->folder.'/'.$tmp_file->file,'diapo/'.$tmp_file->folder.'/'.$tmp_file->file);
|
|
|
-
|
|
|
- Media::create(
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if ($tmp_file) {
|
|
|
+
|
|
|
+ Storage::copy('diapo/tmp/' . $tmp_file->folder . '/' . $tmp_file->file, 'diapo/' . $tmp_file->folder . '/' . $tmp_file->file);
|
|
|
+
|
|
|
+ Media::create(
|
|
|
[
|
|
|
'produit_id' => $article->id,
|
|
|
'diapo' => $tmp_file->folder . '/' . $tmp_file->file,
|
|
|
- ],
|
|
|
- );
|
|
|
- Storage::deleteDirectory('diapo/tmp/'.$tmp_file->folder);
|
|
|
- $tmp_file->delete();
|
|
|
+ ],
|
|
|
+ );
|
|
|
+ Storage::deleteDirectory('diapo/tmp/' . $tmp_file->folder);
|
|
|
+ $tmp_file->delete();
|
|
|
|
|
|
-
|
|
|
- return back()->with('success', 'Image ajouter');
|
|
|
-
|
|
|
- }
|
|
|
- $article->save();
|
|
|
|
|
|
-}
|
|
|
+ return back()->with('success', 'Image ajouter');
|
|
|
+ }
|
|
|
+ $article->save();
|
|
|
+ }
|
|
|
|
|
|
-public function destroyMedia(Request $request, $id){
|
|
|
+ public function destroyMedia(Request $request, $id)
|
|
|
+ {
|
|
|
|
|
|
- $diapo = Media::find($id);
|
|
|
- $diapo->delete();
|
|
|
+ $diapo = Media::find($id);
|
|
|
+ $diapo->delete();
|
|
|
|
|
|
- return back();
|
|
|
-}
|
|
|
+ return back();
|
|
|
+ }
|
|
|
|
|
|
-public function destroyProduit(Request $request, $id){
|
|
|
+ public function destroyProduit(Request $request, $id)
|
|
|
+ {
|
|
|
|
|
|
|
|
|
- // $article = Produit::find($id);
|
|
|
- // $article->delete();
|
|
|
+ // $article = Produit::find($id);
|
|
|
+ // $article->delete();
|
|
|
|
|
|
- // return back();
|
|
|
+ // return back();
|
|
|
|
|
|
- $promo = Promotion::where('produit_id', $id)->count();
|
|
|
- if($promo > 0){
|
|
|
- return redirect ('idara/produits')
|
|
|
- ->with('message', 'Produit existe dans une promotion');
|
|
|
- }
|
|
|
- else{
|
|
|
+ $promo = Promotion::where('produit_id', $id)->count();
|
|
|
+ if ($promo > 0) {
|
|
|
+ return redirect('idara/produits')
|
|
|
+ ->with('message', 'Produit existe dans une promotion');
|
|
|
+ } else {
|
|
|
$article = Produit::find($id);
|
|
|
|
|
|
$article->delete();
|
|
|
return Redirect::to('idara/produits')
|
|
|
- ->with('message', 'produit supprimée');
|
|
|
+ ->with('message', 'produit supprimée');
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
return back();
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-public function fileUploadProduit(Request $request){
|
|
|
-
|
|
|
- if($request->hasfile('image')){
|
|
|
-
|
|
|
- $image = $request->file('image');
|
|
|
- $file = $image->getClientOriginalName();
|
|
|
- $folder = uniqid('post', 'true');
|
|
|
- $image->storeAs('image/tmp/' . $folder,$file,'public');
|
|
|
-
|
|
|
-
|
|
|
- TemporaryFile::create([
|
|
|
- 'folder' => $folder,
|
|
|
- 'file'=> $file
|
|
|
- ]);
|
|
|
- return $folder;
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
- return '';
|
|
|
|
|
|
-
|
|
|
-}
|
|
|
|
|
|
-public function fileDeleteProduit(){
|
|
|
+ public function fileUploadProduit(Request $request)
|
|
|
+ {
|
|
|
|
|
|
-$tmp_file = TemporaryFile::where('folder',request()->getContent())->first();
|
|
|
-if($tmp_file){
|
|
|
- Storage::deleteDirectory('image/tmp/'.$tmp_file->folder);
|
|
|
- $tmp_file->delete();
|
|
|
- return response('');
|
|
|
-}
|
|
|
-}
|
|
|
+ if ($request->hasfile('image')) {
|
|
|
+
|
|
|
+ $image = $request->file('image');
|
|
|
+ $file = $image->getClientOriginalName();
|
|
|
+ $folder = uniqid('post', 'true');
|
|
|
+ $image->storeAs('image/tmp/' . $folder, $file, 'public');
|
|
|
+
|
|
|
+
|
|
|
+ TemporaryFile::create([
|
|
|
+ 'folder' => $folder,
|
|
|
+ 'file' => $file
|
|
|
+ ]);
|
|
|
+ return $folder;
|
|
|
+ }
|
|
|
+ return '';
|
|
|
+ }
|
|
|
+
|
|
|
+ public function fileDeleteProduit()
|
|
|
+ {
|
|
|
+
|
|
|
+ $tmp_file = TemporaryFile::where('folder', request()->getContent())->first();
|
|
|
+ if ($tmp_file) {
|
|
|
+ Storage::deleteDirectory('image/tmp/' . $tmp_file->folder);
|
|
|
+ $tmp_file->delete();
|
|
|
+ return response('');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public function fileUpload(Request $request)
|
|
|
+ {
|
|
|
+
|
|
|
+ if ($request->hasfile('diapo')) {
|
|
|
|
|
|
-public function fileUpload(Request $request){
|
|
|
-
|
|
|
- if($request->hasfile('diapo')){
|
|
|
-
|
|
|
$diapo = $request->file('diapo');
|
|
|
$file = $diapo->getClientOriginalName();
|
|
|
$folder = uniqid('post', 'true');
|
|
|
- $diapo->storeAs('diapo/tmp/' . $folder,$file,'public');
|
|
|
-
|
|
|
+ $diapo->storeAs('diapo/tmp/' . $folder, $file, 'public');
|
|
|
+
|
|
|
|
|
|
- TemporaryFile::create([
|
|
|
+ TemporaryFile::create([
|
|
|
'folder' => $folder,
|
|
|
- 'file'=> $file
|
|
|
- ]);
|
|
|
- return $folder;
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
+ 'file' => $file
|
|
|
+ ]);
|
|
|
+ return $folder;
|
|
|
+ }
|
|
|
return '';
|
|
|
+ }
|
|
|
|
|
|
-
|
|
|
-}
|
|
|
+ public function deleteUpload()
|
|
|
+ {
|
|
|
|
|
|
-public function deleteUpload(){
|
|
|
+ $tmp_file = TemporaryFile::where('folder', request()->getContent())->first();
|
|
|
+ if ($tmp_file) {
|
|
|
+ Storage::deleteDirectory('diapo/tmp/' . $tmp_file->folder);
|
|
|
+ $tmp_file->delete();
|
|
|
+ return response('');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ public function changeStatus(Request $request)
|
|
|
+ {
|
|
|
+ $article = Produit::find($request->Id);
|
|
|
+ $article->etat = $request->etat;
|
|
|
+ $article->save();
|
|
|
|
|
|
- $tmp_file = TemporaryFile::where('folder',request()->getContent())->first();
|
|
|
- if($tmp_file){
|
|
|
- Storage::deleteDirectory('diapo/tmp/'.$tmp_file->folder);
|
|
|
- $tmp_file->delete();
|
|
|
- return response('');
|
|
|
+ return response()->json(['success' => 'Status change successfully.']);
|
|
|
}
|
|
|
-}
|
|
|
-public function changeStatus(Request $request)
|
|
|
-{
|
|
|
- $article = Produit::find($request->Id);
|
|
|
- $article->etat = $request->etat;
|
|
|
- $article->save();
|
|
|
|
|
|
- return response()->json(['success'=>'Status change successfully.']);
|
|
|
-}
|
|
|
+ public function homeStatus(Request $request)
|
|
|
+ {
|
|
|
+ $article = Produit::find($request->Id);
|
|
|
+ $article->home = $request->home;
|
|
|
+ $article->save();
|
|
|
|
|
|
-public function homeStatus(Request $request)
|
|
|
-{
|
|
|
- $article = Produit::find($request->Id);
|
|
|
- $article->home = $request->home;
|
|
|
- $article->save();
|
|
|
+ return response()->json(['success' => 'Status change successfully.']);
|
|
|
+ }
|
|
|
|
|
|
- return response()->json(['success'=>'Status change successfully.']);
|
|
|
-}
|
|
|
|
|
|
+ //doc
|
|
|
+
|
|
|
+ public function editDoc($id)
|
|
|
+ {
|
|
|
+ $article = Produit::find($id);
|
|
|
+ return view('backend.produit.extension.document', ['article' => $article]);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function updateDoc(Request $request, $id)
|
|
|
+ {
|
|
|
+
|
|
|
+ request()->validate([
|
|
|
|
|
|
-//doc
|
|
|
+ 'document' => 'required',
|
|
|
|
|
|
-public function editDoc($id) {
|
|
|
- $article = Produit::find($id);
|
|
|
- return view('backend.produit.extension.document',['article'=>$article]);
|
|
|
-}
|
|
|
|
|
|
-public function updateDoc(Request $request, $id) {
|
|
|
+ ]);
|
|
|
+
|
|
|
+ $tmp_file = temporaryFile::where('folder', $request->document)->first();
|
|
|
+
|
|
|
+
|
|
|
+ $article = Produit::find($id);
|
|
|
+
|
|
|
+ if ($tmp_file) {
|
|
|
+ Storage::copy('document/tmp/' . $tmp_file->folder . '/' . $tmp_file->file, 'document/' . $tmp_file->folder . '/' . $tmp_file->file);
|
|
|
+
|
|
|
+ $article->update([
|
|
|
+
|
|
|
+ "document" => $tmp_file->folder . '/' . $tmp_file->file
|
|
|
+ ]);
|
|
|
+ Storage::deleteDirectory('document/tmp/' . $tmp_file->folder);
|
|
|
+ $tmp_file->delete();
|
|
|
+ }
|
|
|
+
|
|
|
+ $article->save();
|
|
|
|
|
|
- request()->validate([
|
|
|
-
|
|
|
- 'document'=> 'required',
|
|
|
+ return redirect()->route('produit.idara.show', ['id' => $article])->with('success', 'Document Ajouter');
|
|
|
+ }
|
|
|
|
|
|
-
|
|
|
- ]);
|
|
|
+ public function docUpload(Request $request)
|
|
|
+ {
|
|
|
|
|
|
- $tmp_file = temporaryFile::where('folder',$request->document)->first();
|
|
|
+ if ($request->hasfile('document')) {
|
|
|
|
|
|
+ $document = $request->file('document');
|
|
|
+ $file = $document->getClientOriginalName();
|
|
|
+ $folder = uniqid('post', 'true');
|
|
|
+ $document->storeAs('document/tmp/' . $folder, $file, 'public');
|
|
|
|
|
|
-$article = Produit::find($id);
|
|
|
|
|
|
- if($tmp_file){
|
|
|
- Storage::copy('document/tmp/'.$tmp_file->folder.'/'.$tmp_file->file,'document/'.$tmp_file->folder.'/'.$tmp_file->file);
|
|
|
-
|
|
|
- $article->update([
|
|
|
-
|
|
|
- "document" => $tmp_file->folder . '/' . $tmp_file->file
|
|
|
- ]);
|
|
|
- Storage::deleteDirectory('document/tmp/'.$tmp_file->folder);
|
|
|
- $tmp_file->delete();
|
|
|
-
|
|
|
+ TemporaryFile::create([
|
|
|
+ 'folder' => $folder,
|
|
|
+ 'file' => $file
|
|
|
+ ]);
|
|
|
+ return $folder;
|
|
|
+ }
|
|
|
+ return '';
|
|
|
}
|
|
|
-
|
|
|
- $article->save();
|
|
|
-
|
|
|
- return back()->with('success', 'Document Ajouter');
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-public function docUpload(Request $request){
|
|
|
-
|
|
|
- if($request->hasfile('document')){
|
|
|
-
|
|
|
- $document = $request->file('document');
|
|
|
- $file = $document->getClientOriginalName();
|
|
|
- $folder = uniqid('post', 'true');
|
|
|
- $document->storeAs('document/tmp/' . $folder,$file,'public');
|
|
|
-
|
|
|
-
|
|
|
- TemporaryFile::create([
|
|
|
- 'folder' => $folder,
|
|
|
- 'file'=> $file
|
|
|
- ]);
|
|
|
- return $folder;
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+ public function docUploadDelete()
|
|
|
+ {
|
|
|
+
|
|
|
+ $tmp_file = TemporaryFile::where('folder', request()->getContent())->first();
|
|
|
+ if ($tmp_file) {
|
|
|
+ Storage::deleteDirectory('document/tmp/' . $tmp_file->folder);
|
|
|
+ $tmp_file->delete();
|
|
|
+ return response('');
|
|
|
+ }
|
|
|
}
|
|
|
- return '';
|
|
|
+ public function downloadDoc(Produit $produit)
|
|
|
+ {
|
|
|
|
|
|
-
|
|
|
-}
|
|
|
|
|
|
-public function docUploadDelete(){
|
|
|
+ return Storage::download('document/' . $produit->document);
|
|
|
+ }
|
|
|
|
|
|
-$tmp_file = TemporaryFile::where('folder',request()->getContent())->first();
|
|
|
-if($tmp_file){
|
|
|
- Storage::deleteDirectory('document/tmp/'.$tmp_file->folder);
|
|
|
- $tmp_file->delete();
|
|
|
- return response('');
|
|
|
-}
|
|
|
-}
|
|
|
-public function downloadDoc(Produit $produit)
|
|
|
-{
|
|
|
-
|
|
|
-
|
|
|
- return Storage::download('document/'.$produit->document);
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
+ public function deleteDoc(Request $request)
|
|
|
+ {
|
|
|
+
|
|
|
+ $article = Produit::find($request->id);
|
|
|
+ Storage::disk('public')->delete($article->document);
|
|
|
+ Produit::where('document', $article->document)->update(['document' => (new \App\Models\Produit)->defaultDoc()]);
|
|
|
+ // unlink("storage/".$presentation->image);
|
|
|
|
|
|
+ // Presentation::select("image", $presentation->image)->delete();
|
|
|
|
|
|
-}
|
|
|
+ return back()->with("success", "Document deleted successfully.");
|
|
|
+ }
|
|
|
+}
|