Skip to content

Commit

Permalink
Merge pull request #15 from HE-Arc/8-timeline-creation-form
Browse files Browse the repository at this point in the history
8 timeline creation form
  • Loading branch information
theory-of-evrth authored Oct 29, 2024
2 parents cf4e4a5 + e70dca8 commit 949818e
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 3 deletions.
18 changes: 18 additions & 0 deletions timeliner/app/Http/Controllers/TimelineController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Http\Controllers;

use App\Models\Timeline;
use Illuminate\Http\Request;

class TimelineController extends Controller
{
Expand All @@ -11,4 +12,21 @@ public function fetchAllAvailable()
$timelines = Timeline::all();
return view('index', ['timelines'=>$timelines]);
}

public function timelinelist()
{
return view('timeline.timelinelist');
}

public function create()
{
return view('timeline.create');
}

public function store(Request $request)
{
\App\Models\Timeline::create($request->all());
// TODO solve mass assignement problem
return redirect()->route('timeline.timelinelist')->with('success','Timeline created successfully.');
}
}
10 changes: 8 additions & 2 deletions timeliner/resources/views/layouts/app.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,14 @@
@endisset

<!-- Page Content -->
<main>
{{ $slot }}
<main class="container mt-3">
<!-- $slot -->
@if ($message = Session::get('success'))
<div class="alert alert-success">
<p>{{ $message }}</p>
</div>
@endif
@yield('content')
</main>
</div>

Expand Down
64 changes: 64 additions & 0 deletions timeliner/resources/views/timeline/create.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
@extends('layouts.app')

@section('content')
<div class="row mb-3">
<div class="col-12">
<!-- TODO fix route('timeline.fetchAllAvailable') -->
<a class="btn btn-primary" href= "TODO"> Retour</a>
</div>
</div>


<!-- TODO fixe timeline.store -->
<form action="{{ route("timeline.store") }}" method="POST">
@csrf

<div class="row">
<div class="col-12 col-lg-6 offset-0 offset-lg-3">
<div class="card">
<div class="card-header">
Nouveau livre
</div>
<div class="card-body">
<div class="form-row">
<div class="form-group col-12">
<label for="inputTitle">Titre</label>
<input type="text" name="title" class="form-control" id="inputTitle">
</div>
<div class="form-group col-12">
<!-- TODO accecpt only people that are in the database -->
<!-- TODO accecpt several people -->
<label for="inputOwner">Propriétaire</label>
<input type="text" name="title" class="form-control" id="inputOwner">
</div>
<div class="row mt-3">
<div class="form-group col-6">
<label for="selectStartDate">Date de départ</label>
<input type="date" name="startDate" value="{{date('d/m/y')}}" class="form-control" id="selectStartDate">
</div>
<div class="form-group col-6">
<label for="selectEndDate">Date de fin</label>
<input type="date" name="endDate" value="{{date('d/m/y')}}" class="form-control" id="selectEndDate">
</div>
</div>
<div class="form-group col-6">
<!-- TODO button 'Ajouter' redirect to the detail of the newly created timeline -->
<button class="btn btn-primary" href={{ route('timeline.create') }} type="submit" class="btn btn-primary mt-3">Ajouter</button>
</div>
</div>
</div>
</div>
@if ($errors->any())
<div class="alert alert-danger mt-3 col-12">
<strong>Whoops!</strong> Il y a un problème avec vos entrées.<br><br>
<ul>
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
</div>
</div>
</form>
@endsection
4 changes: 3 additions & 1 deletion timeliner/routes/web.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

use App\Http\Controllers\ProfileController;
use App\Http\Controllers\TimelineController;
use App\Http\Controllers\ProfileController;
use Illuminate\Support\Facades\Route;

Route::get('/', [TimelineController::class, 'fetchAllAvailable'])->name('home');
Expand All @@ -26,3 +26,5 @@
});

require __DIR__.'/auth.php';

Route::resource('timeline', TimelineController::class);

0 comments on commit 949818e

Please sign in to comment.