107 lines
2.5 KiB
PHP
107 lines
2.5 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Eleveur;
|
|
use Illuminate\Http\Request;
|
|
|
|
class EleveurController extends Controller
|
|
{
|
|
/**
|
|
* Display a listing of the resource.
|
|
*
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function index()
|
|
{
|
|
$eleveurs = Eleveur::all();
|
|
|
|
return view('eleveurs.index', ['eleveurs' => $eleveurs]);
|
|
}
|
|
|
|
/**
|
|
* Show the form for creating a new resource.
|
|
*
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function create()
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Store a newly created resource in storage.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function store(Request $request)
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Display the specified resource.
|
|
*
|
|
* @param \App\Eleveur $eleveur
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function show(Eleveur $eleveur)
|
|
{
|
|
|
|
}
|
|
|
|
/**
|
|
* Show the form for editing the specified resource.
|
|
*
|
|
* @param \App\Eleveur $eleveur
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function edit(Eleveur $eleveur)
|
|
{
|
|
return view('eleveurs.edit', ['eleveur' => $eleveur]);
|
|
}
|
|
|
|
/**
|
|
* Update the specified resource in storage.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @param \App\Eleveur $eleveur
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function update(Request $request, Eleveur $eleveur)
|
|
{
|
|
$datas = collect($request->all());
|
|
|
|
if ($request->photo1){
|
|
$path = $request->photo1->store('images/photos');
|
|
$path = str_replace('public/', '', $path);
|
|
$datas->put('path_photo1', $path);
|
|
} else {
|
|
$datas->put('path_photo1', $request->input('path_photo1_hidden'));
|
|
}
|
|
|
|
if ($request->photo2){
|
|
$path2 = $request->photo2->store('images/photos');
|
|
$path2 = str_replace('public/', '', $path2);
|
|
$datas->put('path_photo2', $path2);
|
|
} else {
|
|
$datas->put('path_photo2', $request->input('path_photo2_hidden'));
|
|
}
|
|
|
|
$eleveur->update($datas->toArray());
|
|
|
|
return redirect()->route('eleveur.edit', ['eleveur' => $eleveur]);
|
|
}
|
|
|
|
/**
|
|
* Remove the specified resource from storage.
|
|
*
|
|
* @param \App\Eleveur $eleveur
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function destroy(Eleveur $eleveur)
|
|
{
|
|
//
|
|
}
|
|
}
|