Implemented projects.
This commit is contained in:
@@ -0,0 +1,118 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Project;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Requests\ProjectStoreOrUpdate;
|
||||||
|
|
||||||
|
class ProjectsController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$projects = Project::select('id', 'name', 'start_date', 'end_date')
|
||||||
|
->orderBy('name')->get();
|
||||||
|
|
||||||
|
return view('projects.index', compact('projects'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
$project = new Project();
|
||||||
|
|
||||||
|
return view('projects.create', compact('project'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function store(ProjectStoreOrUpdate $request)
|
||||||
|
{
|
||||||
|
$project = new Project();
|
||||||
|
|
||||||
|
$project->name = request('name');
|
||||||
|
$project->start_date = request('start_date');
|
||||||
|
$project->end_date = request('end_date');
|
||||||
|
|
||||||
|
$project->save();
|
||||||
|
|
||||||
|
return redirect('/projects');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified resource.
|
||||||
|
*
|
||||||
|
* @param \App\Project $project
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function show(Project $project)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*
|
||||||
|
* @param \App\Project $project
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function edit(Project $project)
|
||||||
|
{
|
||||||
|
return view('projects.edit', compact('project'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param \App\Project $project
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function update(ProjectStoreOrUpdate $request, Project $project)
|
||||||
|
{
|
||||||
|
$project->name = request('name');
|
||||||
|
$project->start_date = request('start_date');
|
||||||
|
$project->end_date = request('end_date');
|
||||||
|
|
||||||
|
$project->save();
|
||||||
|
|
||||||
|
return redirect('/projects');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the dialog for deleting the specified resource.
|
||||||
|
*
|
||||||
|
* @param \App\Project $project
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function delete(Project $project)
|
||||||
|
{
|
||||||
|
return view('/projects/delete', compact('project'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*
|
||||||
|
* @param \App\Project $project
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function destroy(Project $project)
|
||||||
|
{
|
||||||
|
$project->delete();
|
||||||
|
|
||||||
|
return redirect('/projects');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
class ProjectStoreOrUpdate extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function authorize()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'name' => 'required',
|
||||||
|
'start_date' => 'required|before_or_equal:end_date',
|
||||||
|
'end_date' => 'required',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function messages()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'name.required' => 'Das Projekt muss einen Namen haben.',
|
||||||
|
|
||||||
|
'start_date.required' =>
|
||||||
|
'Das Projekt muss einen Beginn haben.',
|
||||||
|
'start_date.before_or_equal' =>
|
||||||
|
'Der Beginn des Projekts muss vor dem Ende des Projekts liegen.',
|
||||||
|
|
||||||
|
'end_date.required' =>
|
||||||
|
'Das Projekt muss ein Ende haben.'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
@extends('layout.master')
|
||||||
|
|
||||||
|
@section('subnav')
|
||||||
|
<a href='{{ url()->previous() }}'>Zurück</a>
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
<h3>@yield('title')</h3>
|
||||||
|
<form action="/projects/@if (!is_null($project->id)) {{ $project->id }} @endif" method='post'>
|
||||||
|
@if (!is_null($project->id))
|
||||||
|
{{ method_field('patch') }}
|
||||||
|
@endif
|
||||||
|
{{ csrf_field() }}
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td>{{ Form::label('name', 'Name') }}</td>
|
||||||
|
<td>{{ Form::text('name', $project->name) }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>{{ Form::label('start_date', 'Beginn') }}</td>
|
||||||
|
<td>{{ Form::date('start_date', $project->start_date) }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>{{ Form::label('end_date', 'Ende') }}</td>
|
||||||
|
<td>{{ Form::date('end_date', $project->end_date) }}</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
@foreach ($errors->all() as $error)
|
||||||
|
<li>{{ $error }}</li>
|
||||||
|
@endforeach
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<button type="submit" id="submit">Speichern</button>
|
||||||
|
</form>
|
||||||
|
@endsection
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
<ul style='list-style-type: none; padding: 0'>
|
<ul style='list-style-type: none; padding: 0'>
|
||||||
<li><a href='/people'>Personen</a></li>
|
|
||||||
<li><a href='/bookings/year-{{ date('Y') }}'>Kassenbuch</a></li>
|
<li><a href='/bookings/year-{{ date('Y') }}'>Kassenbuch</a></li>
|
||||||
|
<li><a href='/people'>Personen</a></li>
|
||||||
|
<li><a href='/projects/'>Projekte</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
@extends('layout.forms.projects')
|
||||||
|
|
||||||
|
@section('title', 'Neues Projekt')
|
||||||
|
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
@extends('layout.master')
|
||||||
|
|
||||||
|
@section('title', 'Projekt löschen')
|
||||||
|
|
||||||
|
@section('subnav')
|
||||||
|
<a href='{{ url()->previous() }}'>Zurück</a>
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
<form action='/projects/{{ $project->id }}' method='post'>
|
||||||
|
{{ method_field('delete') }}
|
||||||
|
{{ csrf_field() }}
|
||||||
|
<p>Soll das Projekt "<b>{{ $project->name }}</b>" wirklich gelöscht
|
||||||
|
werden?</p>
|
||||||
|
<button type="submit" id="submit">Ja</button>
|
||||||
|
</form>
|
||||||
|
@endsection
|
||||||
|
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
@extends('layout.forms.projects')
|
||||||
|
|
||||||
|
@section('title', 'Projekt bearbeiten')
|
||||||
|
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
@extends('layout.master')
|
||||||
|
|
||||||
|
@section('title', 'Projekte')
|
||||||
|
|
||||||
|
@section('subnav')
|
||||||
|
<a href='/projects/create'>Neues Projekt</a>
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
<h2>@yield('title')</h2>
|
||||||
|
<h3>Aktuelle Projekte</h3>
|
||||||
|
<table border='1'>
|
||||||
|
<tr>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Beginn</th>
|
||||||
|
<th>Ende</th>
|
||||||
|
<th>Aktionen</th>
|
||||||
|
</tr>
|
||||||
|
@foreach($projects->where('start_date', '<=', now())
|
||||||
|
->where('end_date', '>=', now()) as $project)
|
||||||
|
<tr>
|
||||||
|
<td>{{ $project->name }}</td>
|
||||||
|
<td>{{ formatDate($project->start_date) }}</td>
|
||||||
|
<td>{{ formatDate($project->end_date) }}</td>
|
||||||
|
<td>
|
||||||
|
<a href='/projects/{{ $project->id }}/edit'>Bearbeiten</a><br />
|
||||||
|
<a href='/projects/{{ $project->id }}/delete'>Löschen</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
@endforeach
|
||||||
|
</table>
|
||||||
|
<h3>Kommende Projekte</h3>
|
||||||
|
<table border='1'>
|
||||||
|
<tr>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Beginn</th>
|
||||||
|
<th>Ende</th>
|
||||||
|
<th>Aktionen</th>
|
||||||
|
</tr>
|
||||||
|
@foreach($projects->where('start_date', '>', now()) as $project)
|
||||||
|
<tr>
|
||||||
|
<td>{{ $project->name }}</td>
|
||||||
|
<td>{{ formatDate($project->start_date) }}</td>
|
||||||
|
<td>{{ formatDate($project->end_date) }}</td>
|
||||||
|
<td>
|
||||||
|
<a href='/projects/{{ $project->id }}/edit'>Bearbeiten</a><br />
|
||||||
|
<a href='/projects/{{ $project->id }}/delete'>Löschen</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
@endforeach
|
||||||
|
</table>
|
||||||
|
<h3>Vergangene Projekte</h3>
|
||||||
|
<table border='1'>
|
||||||
|
<tr>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Beginn</th>
|
||||||
|
<th>Ende</th>
|
||||||
|
<th>Aktionen</th>
|
||||||
|
</tr>
|
||||||
|
@foreach($projects->where('end_date', '<', now()) as $project)
|
||||||
|
<tr>
|
||||||
|
<td>{{ $project->name }}</td>
|
||||||
|
<td>{{ formatDate($project->start_date) }}</td>
|
||||||
|
<td>{{ formatDate($project->end_date) }}</td>
|
||||||
|
<td>
|
||||||
|
<a href='/projects/{{ $project->id }}/edit'>Bearbeiten</a><br />
|
||||||
|
<a href='/projects/{{ $project->id }}/delete'>Löschen</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
@endforeach
|
||||||
|
</table>
|
||||||
|
@endsection
|
||||||
+13
-1
@@ -32,9 +32,21 @@ Route::get('/bookings/year-{year}', 'BookingsController@index');
|
|||||||
Route::post('/bookings', 'BookingsController@store');
|
Route::post('/bookings', 'BookingsController@store');
|
||||||
|
|
||||||
Route::get('/bookings/create', 'BookingsController@create');
|
Route::get('/bookings/create', 'BookingsController@create');
|
||||||
Route::get('/bookings/{booking}', 'BookingsController@show');
|
|
||||||
Route::patch('/bookings/{booking}', 'BookingsController@update');
|
Route::patch('/bookings/{booking}', 'BookingsController@update');
|
||||||
Route::delete('/bookings/{booking}', 'BookingsController@destroy');
|
Route::delete('/bookings/{booking}', 'BookingsController@destroy');
|
||||||
|
|
||||||
Route::get('/bookings/{booking}/edit', 'BookingsController@edit');
|
Route::get('/bookings/{booking}/edit', 'BookingsController@edit');
|
||||||
Route::get('/bookings/{booking}/delete', 'BookingsController@delete');
|
Route::get('/bookings/{booking}/delete', 'BookingsController@delete');
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
* PROJECTS *
|
||||||
|
******************************************************************************/
|
||||||
|
Route::get('/projects', 'ProjectsController@index');
|
||||||
|
Route::post('/projects', 'ProjectsController@store');
|
||||||
|
|
||||||
|
Route::get('/projects/create', 'ProjectsController@create');
|
||||||
|
Route::patch('/projects/{project}', 'ProjectsController@update');
|
||||||
|
Route::delete('/projects/{project}', 'ProjectsController@destroy');
|
||||||
|
|
||||||
|
Route::get('/projects/{project}/edit', 'ProjectsController@edit');
|
||||||
|
Route::get('/projects/{project}/delete', 'ProjectsController@delete');
|
||||||
|
|||||||
Reference in New Issue
Block a user