mirror of
https://gitlab.com/TheGamecraft/c-cms.git
synced 2026-04-21 18:59:09 -04:00
111 lines
2.6 KiB
PHP
111 lines
2.6 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Picture;
|
|
use Illuminate\Http\Request;
|
|
|
|
class PictureController extends Controller
|
|
{
|
|
/**
|
|
* Display a listing of the resource.
|
|
*
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function index()
|
|
{
|
|
return view('public.allpicture',['pictures' => \App\Picture::paginate(\App\Config::getData('text_public_picture_nb'))]);
|
|
}
|
|
|
|
public function indexAdmin()
|
|
{
|
|
return view('admin.picture.index',['pictures' => \App\Picture::paginate(\App\Config::getData('text_public_picture_nb'))]);
|
|
}
|
|
/**
|
|
* Show the form for creating a new resource.
|
|
*
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function create()
|
|
{
|
|
return view('admin.picture.add');
|
|
}
|
|
|
|
/**
|
|
* Store a newly created resource in storage.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function store()
|
|
{
|
|
$pic = new Picture();
|
|
|
|
$pic->title = request('title');
|
|
$pic->url = request('url');
|
|
$pic->desc = request('desc');
|
|
$pic->pictureable_id = 0;
|
|
$pic->pictureable_type = "";
|
|
|
|
$pic->save();
|
|
|
|
return redirect('/admin/picture')->with('success','Image ajoutée avec succès');
|
|
|
|
}
|
|
|
|
/**
|
|
* Display the specified resource.
|
|
*
|
|
* @param \App\Picture $picture
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function show($id)
|
|
{
|
|
return view('public.picture',['picture' => \App\Picture::find($id)]);
|
|
}
|
|
|
|
/**
|
|
* Show the form for editing the specified resource.
|
|
*
|
|
* @param \App\Picture $picture
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function edit($id)
|
|
{
|
|
return view('admin.picture.edit',['picture' => Picture::find($id)]);
|
|
}
|
|
|
|
/**
|
|
* Update the specified resource in storage.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @param \App\Picture $picture
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function update($id)
|
|
{
|
|
$pic = Picture::find($id);
|
|
|
|
$pic->title = request('title');
|
|
$pic->url = request('url');
|
|
$pic->desc = request('desc');
|
|
|
|
$pic->save();
|
|
|
|
return redirect('/admin/picture')->with('success','Image sauvegarder avec succès');
|
|
}
|
|
|
|
/**
|
|
* Remove the specified resource from storage.
|
|
*
|
|
* @param \App\Picture $picture
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function destroy($id)
|
|
{
|
|
$pic = Picture::find($id);
|
|
|
|
$pic->delete();
|
|
}
|
|
}
|