mirror of
https://gitlab.com/TheGamecraft/c-cms.git
synced 2026-04-21 02:39:10 -04:00
147 lines
4.0 KiB
PHP
147 lines
4.0 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\ComplementaryActivity;
|
|
use Illuminate\Http\Request;
|
|
|
|
class ComplementaryActivityController extends Controller
|
|
{
|
|
/**
|
|
* Display a listing of the resource.
|
|
*
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function index()
|
|
{
|
|
return view('admin.configs.activity',['configs' => \App\Config::all(),'activities' => \App\ComplementaryActivity::all()]);
|
|
}
|
|
|
|
/**
|
|
* Show the form for creating a new resource.
|
|
*
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function create()
|
|
{
|
|
return view('admin.configs.activity-add');
|
|
}
|
|
|
|
/**
|
|
* Store a newly created resource in storage.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function store()
|
|
{
|
|
$activity = new ComplementaryActivity();
|
|
|
|
$activity->name = request('name');
|
|
$activity->admin_desc = request('admin_desc');
|
|
$activity->public_body = 'Veuillez modifier le text de description publique par défaut';
|
|
$activity->calendar_color = request('calendar_color');
|
|
$activity->calendar_icon = request('calendar_icon');
|
|
$activity->begin_time = request('begin_time');
|
|
$activity->end_time = request('end_time');
|
|
$activity->location = request('location');
|
|
if(request('is_mandatory') == 'on')
|
|
{
|
|
$activity->is_mandatory = true;
|
|
}
|
|
else
|
|
{
|
|
$activity->is_mandatory = false;
|
|
}
|
|
if(request('is_promoted') == 'on')
|
|
{
|
|
$activity->is_promoted = true;
|
|
}
|
|
else
|
|
{
|
|
$activity->is_promoted = false;
|
|
}
|
|
|
|
$activity->save();
|
|
|
|
return redirect('/admin/config/activity')->with('status','Activité ajouté avec succes');
|
|
}
|
|
|
|
/**
|
|
* Display the specified resource.
|
|
*
|
|
* @param \App\ComplementaryActivity $complementaryActivity
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function show(ComplementaryActivity $complementaryActivity)
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Show the form for editing the specified resource.
|
|
*
|
|
* @param \App\ComplementaryActivity $complementaryActivity
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function edit($id)
|
|
{
|
|
return view('admin.configs.activity-edit',['activity' => \App\ComplementaryActivity::find($id)]);
|
|
}
|
|
|
|
/**
|
|
* Update the specified resource in storage.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @param \App\ComplementaryActivity $complementaryActivity
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function update($id)
|
|
{
|
|
$activity = ComplementaryActivity::find($id);
|
|
|
|
$activity->name = request('name');
|
|
$activity->admin_desc = request('admin_desc');
|
|
$activity->calendar_color = request('calendar_color');
|
|
$activity->calendar_icon = request('calendar_icon');
|
|
$activity->begin_time = request('begin_time');
|
|
$activity->end_time = request('end_time');
|
|
$activity->location = request('location');
|
|
if(request('is_mandatory') == 'on')
|
|
{
|
|
$activity->is_mandatory = true;
|
|
}
|
|
else
|
|
{
|
|
$activity->is_mandatory = false;
|
|
}
|
|
if(request('is_promoted') == 'on')
|
|
{
|
|
$activity->is_promoted = true;
|
|
}
|
|
else
|
|
{
|
|
$activity->is_promoted = false;
|
|
}
|
|
|
|
$activity->save();
|
|
|
|
return redirect('/admin/config/activity')->with('success','Modification sauvegarder avec succes');
|
|
}
|
|
|
|
/**
|
|
* Remove the specified resource from storage.
|
|
*
|
|
* @param \App\ComplementaryActivity $complementaryActivity
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function destroy()
|
|
{
|
|
$id = request('id');
|
|
|
|
$activity = ComplementaryActivity::find($id);
|
|
|
|
$activity->delete();
|
|
}
|
|
}
|