Skip to content
This repository has been archived by the owner on Jan 10, 2022. It is now read-only.

Commit

Permalink
Merge branch 'release/betav2' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
jestin-g committed Jan 3, 2021
2 parents 980ccef + 48ca5b7 commit 7ef8790
Show file tree
Hide file tree
Showing 13 changed files with 424 additions and 11,126 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/node_modules
/public/hot
/public/storage
/public/images
/public/css
/public/js
/storage/*.key
Expand Down
13 changes: 12 additions & 1 deletion app/Http/Controllers/EventController.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public function index()
$events = Event::with('types')
->orderBy('date', 'asc')
->get();

$typesEvents = EventType::orderBy('label', 'asc')->get();

return Inertia::render('Event/Index', [
Expand Down Expand Up @@ -63,16 +64,26 @@ public function store(Request $request)
'date' => ['required'],
'description' => ['required', 'max:500'],
'value' => ['required']
], [
'title.required' => 'Le titre est obligatoire.',
'title.max' => 'Le titre ne doit pas dépasser :max caractères.',
'location.required'=> 'La localisation est obligatoire.',
'date.required'=> 'La date est obligatoire.',
'description.required'=> 'La description est obligatoire.',
'description.max' => 'La description ne doit pas dépasser :max caractères.',
'value.required'=> 'Veuillez choisir au moins une valeur dans la liste.',
]);


$event = Event::create($request->all());

/* Récupère les id des types d'événement à attacher à l'événement */
$typesToAdd = array();

foreach ($request->value as $types) {
array_push($typesToAdd, $types["id"]);
}

/* Ajoute le ou les types a l'événement */
foreach ($typesToAdd as $typeId) {
$event->types()->attach($typeId);
}
Expand Down
48 changes: 23 additions & 25 deletions app/Http/Controllers/SearchController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,40 +23,38 @@ public function index()
} else {
$events = Event::orderBy('date', 'asc')
->whereDate('date', '>=', date('Y-m-d'))
->get()
->take(3);
->get();
return Inertia::render('Search', compact('events'));
}
}

/**
* Retourne une liste d'événements au format JSON
*
* @return Illuminate\Contracts\Routing\ResponseFactory::json
*/
public function search()
{
if (request('q') != null) {
$events = Event::where('title', 'like', request('q') . '%')->get();
return response()->json($events);
//return Inertia::render('/', ['events' => $events]);
} else {
$events = Event::orderBy('date', 'asc')->get()->take(3);
return response()->json($events);

public function search(){

if( request('q') != null)
{
$events = Event::where('title', 'like', request('q') . '%')->get();
return response()->json($events);
//return Inertia::render('/', ['events' => $events]);
}
}

// Show event into map
// Show event into map

public function showSomeEventsOntoMap(Request $request)
{
$request->validate([
'Code_Postal' => ['required','min:5','max:5']
]);
public function showSomeEventsOntoMap(Request $request)
{
$request->validate([
'Code_Postal' => ['required','min:5','max:5']
],[
'Code_Postal.required' => 'Veuillez renseigner le champ avec un code postal valide',
'Code_Postal.min' => 'Veuillez renseigner le champ avec un code postal valide',
'Code_Postal.max' => 'Veuillez renseigner le champ avec un code postal valide'
]);

$address = Event::select('location','title','date')->where('location', 'like', '%'.request('Code_Postal'))->get();
$address = Event::select('location','title','date')->where('location', 'like', '%'.request('Code_Postal'))->get();

return Inertia::render('AllEventsOnToMap', compact('address'));
return Inertia::render('AllEventsOnToMap', compact('address'));

}

}
}
2 changes: 1 addition & 1 deletion app/Models/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Event extends Model
'location',
'date',
'description'
];
];

public function types()
{
Expand Down
Loading

0 comments on commit 7ef8790

Please sign in to comment.