-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
3 changed files
with
126 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use Illuminate\Http\Request; | ||
use Illuminate\Support\Facades\Log; | ||
|
||
use App\Http\Requests; | ||
use App\Perso; | ||
|
||
|
||
class PersoController extends Controller | ||
{ | ||
/** | ||
* Display a listing of the resource. | ||
* | ||
* @return \Illuminate\Http\Response | ||
*/ | ||
public function index() | ||
{ | ||
return view('persos', [ | ||
'persos' => Perso::orderBy('created_at', 'asc')->get() | ||
]); | ||
} | ||
|
||
/** | ||
* 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) | ||
{ | ||
$perso = new Perso; | ||
$perso->user_id = 1; | ||
$perso->name = $request->input('name'); | ||
$perso->race = $request->input('race'); | ||
|
||
Log::info('Ajout du perso', ['perso' => $perso]); | ||
$perso->save(); | ||
return redirect('/persos'); | ||
} | ||
|
||
/** | ||
* 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) | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* Update the specified resource in storage. | ||
* | ||
* @param \Illuminate\Http\Request $request | ||
* @param int $id | ||
* @return \Illuminate\Http\Response | ||
*/ | ||
public function update(Request $request, $id) | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* Remove the specified resource from storage. | ||
* | ||
* @param int $id | ||
* @return \Illuminate\Http\Response | ||
*/ | ||
public function destroy($id) | ||
{ | ||
// | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,33 @@ | ||
@extends('layouts.app') | ||
|
||
@section('content') | ||
<div class="row"> | ||
<form class="col s12" action="{{url('perso')}}" method="POST"> | ||
{{ csrf_field() }} | ||
<h2>Nouveau personnage</h2> | ||
<div class="row"> | ||
<div class="input-field col s6"> | ||
<input id="name" type="text" class="validate"> | ||
<label for="name">Nom</label> | ||
</div> | ||
<div class="input-field col s6"> | ||
<input id="race" type="text" class="validate"> | ||
<label for="race">Race</label> | ||
</div> | ||
<form class="col s12" action="{{url('persos')}}" method="POST"> | ||
{{ csrf_field() }} | ||
<h2>Nouveau personnage</h2> | ||
<div class="row"> | ||
<div class="input-field col s6"> | ||
<input id="perso-name" name="name" type="text" class="validate"> | ||
<label for="perso-name">Nom</label> | ||
</div> | ||
<div class="input-field col s6"> | ||
<input id="perso-race" name="race" type="text" class="validate"> | ||
<label for="perso-race">Race</label> | ||
</div> | ||
</div> | ||
<div class="row"> | ||
<button class="btn waves-effect waves-light" type="submit" name="action">Créer | ||
<i class="material-icons right">send</i> | ||
</button> | ||
</div> | ||
</form> | ||
</div> | ||
<div class="row"> | ||
<button class="btn waves-effect waves-light" type="submit" name="action">Créer | ||
<i class="material-icons right">send</i> | ||
</button> | ||
</div> | ||
</form> | ||
</div> | ||
|
||
@if (count($persos) > 0) | ||
<div class="collection"> | ||
@foreach ($persos as $perso) | ||
<li class="collection-item">{{ $perso->name }} ({{ $perso->race }})</li> | ||
@endforeach | ||
</div> | ||
@endif | ||
@if (count($persos) > 0) | ||
<div class="collection"> | ||
@foreach ($persos as $perso) | ||
<li class="collection-item">{{ $perso->name }} ({{ $perso->race }})</li> | ||
@endforeach | ||
</div> | ||
@endif | ||
@endsection |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters