diff --git a/.env.example b/.env.example index aecf471c..94a53230 100644 --- a/.env.example +++ b/.env.example @@ -4,9 +4,6 @@ APP_DEBUG=true APP_LOG_LEVEL=debug APP_URL=http://localhost:8000 -TELESCOPE_ENABLED=true -TELESCOPE_PROD=false - DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 diff --git a/app/AgendaItem.php b/app/AgendaItem.php index 91b408c4..fb7c0c9d 100644 --- a/app/AgendaItem.php +++ b/app/AgendaItem.php @@ -7,6 +7,7 @@ use Carbon\Carbon; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\HasOne; +use Illuminate\Support\Facades\Storage; class AgendaItem extends Model { @@ -19,33 +20,21 @@ class AgendaItem extends Model 'endDate', 'image_url', 'category', - 'climbing_activity' + 'climbing_activity', ]; protected $casts = [ - 'climbing_activity' => 'boolean' + 'climbing_activity' => 'boolean', ]; - public function getApplicationForm(): HasOne{ - return $this->hasOne(ApplicationForm::class,'id',"application_form_id"); - } - - public function agendaItemText(){ - return $this->hasOne('App\Text', 'id', 'text'); - } - - public function agendaItemTitle() + public function getApplicationForm(): HasOne { - return $this->hasOne('App\Text', 'id', 'title'); - } - public function agendaItemShortDescription() - { - return $this->hasOne('App\Text', 'id', 'shortDescription'); + return $this->hasOne(ApplicationForm::class, 'id', "application_form_id"); } public function agendaItemCategory() { - return $this->hasOne('App\AgendaItemCategorie', 'id', 'category')->withTrashed(); + return $this->hasOne('App\AgendaItemCategory', 'id', 'category')->withTrashed(); } public function getCreatedBy() @@ -53,23 +42,26 @@ public function getCreatedBy() return $this->hasOne('App\User', 'id', 'createdBy'); } - public function getImageUrl(){ - if($this->image_url != ""){ - return \Storage::disk('public')->url($this->image_url); + public function getImageUrl() + { + if ($this->image_url != "") { + return Storage::disk('public')->url($this->image_url); } else { return "/img/default_agenda_item_cover.jpg"; } } - public function getApplicationFormResponses(){ - return $this->hasMany(ApplicationResponse::class,'agenda_id'); + public function getApplicationFormResponses() + { + return $this->hasMany(ApplicationResponse::class, 'agenda_id'); } - public function canRegister(){ - if($this->subscription_endDate < Carbon::now()){ + public function canRegister() + { + if ($this->subscription_endDate < Carbon::now()) { return false; } else { return true; } } -} \ No newline at end of file +} diff --git a/app/AgendaItemCategorie.php b/app/AgendaItemCategory.php similarity index 50% rename from app/AgendaItemCategorie.php rename to app/AgendaItemCategory.php index 56644f22..9105b3fd 100644 --- a/app/AgendaItemCategorie.php +++ b/app/AgendaItemCategory.php @@ -5,14 +5,11 @@ use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\SoftDeletes; -class AgendaItemCategorie extends Model +class AgendaItemCategory extends Model { use SoftDeletes; + protected $fillable = [ - 'name' + 'name', ]; - - public function categorieName(){ - return $this->hasOne('App\Text', 'id', 'name')->withTrashed(); - } } diff --git a/app/Certificate.php b/app/Certificate.php index 4c8883f8..bb815ba1 100644 --- a/app/Certificate.php +++ b/app/Certificate.php @@ -10,12 +10,6 @@ class Certificate extends Model use SoftDeletes; protected $fillable = [ 'name', - 'duration', - 'abbreviation' + 'abbreviation', ]; - - public function certificateName(){ - return $this->hasOne('App\Text', 'id', 'name'); - } - } diff --git a/app/Console/Commands/RemoveOldApplications.php b/app/Console/Commands/RemoveOldApplications.php index 7f5fa53b..4a0d10e2 100644 --- a/app/Console/Commands/RemoveOldApplications.php +++ b/app/Console/Commands/RemoveOldApplications.php @@ -40,7 +40,7 @@ public function __construct() public function handle() { ApplicationResponse::query() - ->where('created_at','<',Carbon::now()->subYear(config('custom.application_response_save_period'))) + ->where('created_at', '<', Carbon::now()->subYears(config('custom.application_response_save_period'))) ->forceDelete(); } } diff --git a/app/Console/Commands/RemoveOldUsers.php b/app/Console/Commands/RemoveOldUsers.php index b37e7a68..fb3dfea7 100644 --- a/app/Console/Commands/RemoveOldUsers.php +++ b/app/Console/Commands/RemoveOldUsers.php @@ -40,7 +40,7 @@ public function __construct() public function handle() { User::query() - ->whereDate('lid_af','<',Carbon::now()->subYear(config('custom.old_users_save_period'))) + ->whereDate('lid_af', '<', Carbon::now()->subYears(config('custom.old_users_save_period'))) ->update([ 'email' => null, 'password' => null, diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index e24741b0..8a67eca3 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -2,7 +2,6 @@ namespace App\Console; -use App\Console\Commands\RemoveOldUsers; use Illuminate\Console\Scheduling\Schedule; use Illuminate\Foundation\Console\Kernel as ConsoleKernel; @@ -25,10 +24,10 @@ class Kernel extends ConsoleKernel */ protected function schedule(Schedule $schedule) { - $schedule->command('remove:oldUsers') - ->weekly(); - $schedule->command('remove:oldApplications') - ->weekly(); + $schedule->command('remove:oldUsers') + ->weekly(); + $schedule->command('remove:oldApplications') + ->weekly(); } /** diff --git a/app/CustomClasses/MailList/MailList.php b/app/CustomClasses/MailList/MailList.php index 2f00a16b..e6397484 100644 --- a/app/CustomClasses/MailList/MailList.php +++ b/app/CustomClasses/MailList/MailList.php @@ -8,7 +8,6 @@ namespace App\CustomClasses\MailList; - class MailList { private $id; @@ -103,7 +102,7 @@ public function getMembers(): array */ public function addMember(MailListMember $member): MailList { - array_push($this->members,$member); + array_push($this->members, $member); return $this; } -} \ No newline at end of file +} diff --git a/app/CustomClasses/MailList/MailListFacade.php b/app/CustomClasses/MailList/MailListFacade.php index 4ea39dad..cd31388e 100644 --- a/app/CustomClasses/MailList/MailListFacade.php +++ b/app/CustomClasses/MailList/MailListFacade.php @@ -13,27 +13,29 @@ class MailListFacade private $_mailListParser; private $_mailManHandler; - public function __construct(MailListParser $mailListParser,MailMan $mailMan) + public function __construct(MailListParser $mailListParser, MailMan $mailMan) { $this->_mailListParser = $mailListParser; $this->_mailManHandler = $mailMan; } - public function getAllMailLists(){ + public function getAllMailLists() + { $mailLists = array(); $response = $this->_mailManHandler->get('/lists'); - foreach($response->entries as $mailList){ - array_push($mailLists,$this->_mailListParser->parseMailManMailList($mailList)); + foreach ($response->entries as $mailList) { + array_push($mailLists, $this->_mailListParser->parseMailManMailList($mailList)); } return $mailLists; } - public function getMailList($id){ + public function getMailList($id) + { $mailList = $this->_mailListParser->parseMailManMailList($this->_mailManHandler->get('/lists/' . $id)); $members = $this->_mailManHandler->get('/lists/' . $id . '/roster/member'); - if(property_exists($members,"entries")){ - foreach ($members->entries as $member){ + if (property_exists($members, "entries")) { + foreach ($members->entries as $member) { $parsedMember = $this->_mailListParser->parseMailManMember($member); $mailList->addMember($parsedMember); } @@ -42,21 +44,25 @@ public function getMailList($id){ return $mailList; } - public function storeMailList(array $data){ + public function storeMailList(array $data) + { $this->_mailManHandler->post("/lists", [ 'fqdn_listname' => $data['address'] . env("MAIL_MAN_DOMAIN"), ]); } - public function deleteMailList($id){ + public function deleteMailList($id) + { $this->_mailManHandler->delete("/lists/" . $id); } - public function deleteMemberFromMailList($mailListId,$memberEmail){ - $this->_mailManHandler->delete("/lists/" . $mailListId ."/member/". $memberEmail); + public function deleteMemberFromMailList($mailListId, $memberEmail) + { + $this->_mailManHandler->delete("/lists/" . $mailListId . "/member/" . $memberEmail); } - public function addMember($mailListId, $email,$name){ + public function addMember($mailListId, $email, $name) + { $this->_mailManHandler->post( "/members", [ @@ -70,28 +76,30 @@ public function addMember($mailListId, $email,$name){ ); } - public function deleteUserFormAllMailList($user){ - foreach ($this->getAllMailLists() as $mailList){ + public function deleteUserFormAllMailList($user) + { + foreach ($this->getAllMailLists() as $mailList) { try { //we used try to delete the user from the mail list wihout checken if he is in the list because //that take to much time - $this->deleteMemberFromMailList($mailList->getId(),$user->email); - } catch (\Exception $e){ + $this->deleteMemberFromMailList($mailList->getId(), $user->email); + } catch (\Exception $e) { } } } - public function updateUserEmailFormAllMailList($user, $oldEmail, $newEmail){ - foreach ($this->getAllMailLists() as $mailList){ + public function updateUserEmailFormAllMailList($user, $oldEmail, $newEmail) + { + foreach ($this->getAllMailLists() as $mailList) { $mailList = $this->getMailList($mailList->getAddress()); - foreach ($mailList->getMembers() as $member){ - if($oldEmail === $member->getAddress()){ - $this->deleteMemberFromMailList($mailList->getId(),$member->getAddress()); - $this->addMember($mailList->getId(),$newEmail,$user->getName()); + foreach ($mailList->getMembers() as $member) { + if ($oldEmail === $member->getAddress()) { + $this->deleteMemberFromMailList($mailList->getId(), $member->getAddress()); + $this->addMember($mailList->getId(), $newEmail, $user->getName()); } } } } -} \ No newline at end of file +} diff --git a/app/CustomClasses/MailList/MailListMember.php b/app/CustomClasses/MailList/MailListMember.php index d18650bb..7f8cf5e3 100644 --- a/app/CustomClasses/MailList/MailListMember.php +++ b/app/CustomClasses/MailList/MailListMember.php @@ -8,7 +8,6 @@ namespace App\CustomClasses\MailList; - class MailListMember { private $name; @@ -49,4 +48,4 @@ public function setAddress($address) $this->address = $address; return $this; } -} \ No newline at end of file +} diff --git a/app/CustomClasses/MailList/MailListParser.php b/app/CustomClasses/MailList/MailListParser.php index 438dbac4..8be2c1f0 100644 --- a/app/CustomClasses/MailList/MailListParser.php +++ b/app/CustomClasses/MailList/MailListParser.php @@ -21,7 +21,8 @@ class MailListParser * @param $object * @return MailList */ - public function parseMailManMailList($object) : MailList{ + public function parseMailManMailList($object): MailList + { $mailList = new MailList(); $mailList ->setId($object->list_id) @@ -36,7 +37,8 @@ public function parseMailManMailList($object) : MailList{ * @param $object * @return MailListMember */ - public function parseMailManMember($object) : MailListMember{ + public function parseMailManMember($object): MailListMember + { $member = new MailListMember(); $member ->setAddress($object->email) @@ -44,4 +46,4 @@ public function parseMailManMember($object) : MailListMember{ return $member; } -} \ No newline at end of file +} diff --git a/app/CustomClasses/MailList/MailMan.php b/app/CustomClasses/MailList/MailMan.php index 9bfc225d..01ce9508 100644 --- a/app/CustomClasses/MailList/MailMan.php +++ b/app/CustomClasses/MailList/MailMan.php @@ -8,7 +8,6 @@ namespace App\CustomClasses\MailList; - use GuzzleHttp\Client; class MailMan @@ -22,27 +21,31 @@ public function __construct() $this->_client = new Client(); } - public function get(string $url){ - return $this->call("GET",$url); + public function get(string $url) + { + return $this->call("GET", $url); } - public function post(string $url,array $body){ - return $this->call("POST",$url,$body); + public function post(string $url, array $body) + { + return $this->call("POST", $url, $body); } - public function delete(string $url){ - return $this->call("DELETE",$url); + public function delete(string $url) + { + return $this->call("DELETE", $url); } - private function call(string $method,string $url,array $body = []){ - $response = $this->_client->request($method,$this->_baseUrl . $url,[ + private function call(string $method, string $url, array $body = []) + { + $response = $this->_client->request($method, $this->_baseUrl . $url, [ "form_params" => $body, "auth" => [ env('MAIL_MAN_USERNAME'), - env('MAIL_MAN_PASSWORD') - ] + env('MAIL_MAN_PASSWORD'), + ], ]); return json_decode($response->getBody()->getContents()); } -} \ No newline at end of file +} diff --git a/app/CustomClasses/MenuSingleton.php b/app/CustomClasses/MenuSingleton.php index 2944c75d..7446bba4 100644 --- a/app/CustomClasses/MenuSingleton.php +++ b/app/CustomClasses/MenuSingleton.php @@ -10,23 +10,26 @@ class MenuSingleton private $_subMenuItems = array(); // containts the submenu items from a menu item const MENUSINGLETON = "MenuSingleton"; - public function __construct() { + public function __construct() + { $menu = new MenuItem(); $this->_menuItems = $menu->sortMeunuList($menu->getMenuItems()); - foreach ($this->_menuItems as $menuItem){ + foreach ($this->_menuItems as $menuItem) { $this->_subMenuItems[$menuItem->id] = $menu->sortMeunuList($menu->getSubMenuItems($menuItem->id)); } } - public function getMenuItems(){ + public function getMenuItems() + { return $this->_menuItems; } - public function getSubMenuItem($menuId){ - if(array_key_exists($menuId,$this->_subMenuItems)){ + public function getSubMenuItem($menuId) + { + if (array_key_exists($menuId, $this->_subMenuItems)) { return $this->_subMenuItems[$menuId]; } else { return array(); } } -} \ No newline at end of file +} diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index c6b123b9..3be90f2b 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -3,13 +3,10 @@ namespace App\Exceptions; use App\CustomClasses\MenuSingleton; -use App\MenuItem; -use Throwable; -use Illuminate\Auth\Access\AuthorizationException; use Illuminate\Auth\AuthenticationException; use Illuminate\Contracts\Container\Container; use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; -use Illuminate\Validation\UnauthorizedException; +use Throwable; class Handler extends ExceptionHandler { @@ -56,20 +53,20 @@ public function report(Throwable $exception) */ public function render($request, Throwable $exception) { - if($this->_menu === null){ - $this->_menu = new MenuSingleton(new MenuItem()); + if ($this->_menu === null) { + $this->_menu = new MenuSingleton(); } - if(method_exists($exception,"getStatusCode")){ + if (method_exists($exception, "getStatusCode")) { $menu = $this->_menu; - $curPageName = trans('validation.error'); - switch ($exception->getStatusCode()){ + $curPageName = 'Error'; + switch ($exception->getStatusCode()) { case 403: - return response()->view('errors.403',compact('menu','curPageName'),403); + return response()->view('errors.403', compact('menu', 'curPageName'), 403); case 404: - return response()->view('errors.404',compact('menu','curPageName'),404); + return response()->view('errors.404', compact('menu', 'curPageName'), 404); case 503: - return response()->view('errors.503',compact('menu','curPageName'),503); + return response()->view('errors.503', compact('menu', 'curPageName'), 503); default: return parent::render($request, $exception); } @@ -77,9 +74,6 @@ public function render($request, Throwable $exception) return parent::render($request, $exception); } - - - } /** diff --git a/app/Exports/AgendaRegistrationExport.php b/app/Exports/AgendaRegistrationExport.php index 4b6e35e4..767d8e1d 100644 --- a/app/Exports/AgendaRegistrationExport.php +++ b/app/Exports/AgendaRegistrationExport.php @@ -3,7 +3,6 @@ namespace App\Exports; use App\AgendaItem; -use App\Repositories\InschrijvenRepository; use App\Services\AgendaApplicationFormService; use Maatwebsite\Excel\Concerns\FromCollection; use Maatwebsite\Excel\Concerns\ShouldAutoSize; @@ -38,8 +37,8 @@ public function __construct(AgendaApplicationFormService $agendaApplicationFormS } /** - * @return \Illuminate\Support\Collection - */ + * @return \Illuminate\Support\Collection + */ public function collection() { return $this->agendaApplicationFormService->getExportData($this->agendaItem); @@ -50,7 +49,7 @@ public function collection() */ public function title(): string { - return trans('forms.Inschrijvingen'); + return 'Subscriptions'; } /** @@ -59,20 +58,20 @@ public function title(): string public function headings(): array { $defaultValues = [ - trans('user.firstname'), - trans('user.preposition'), - trans('user.lastname'), - trans('user.street'), - trans('user.housenumber'), - trans('user.city'), - trans('user.email'), - trans('user.phonenumber'), + 'First name', + 'Preposition', + 'Last name', + 'Street', + 'House number', + 'City', + 'Email address', + 'Phone number', ]; $formQuestions = []; $rows = $this->agendaItem->getApplicationForm->applicationFormRows; foreach ($rows as $row) { - $formQuestions[] = $row->applicationFormRowName->text(); + $formQuestions[] = $row->name; } return array_merge($defaultValues, $formQuestions); diff --git a/app/Exports/UsersExport.php b/app/Exports/UsersExport.php index 15157d7a..0330b2ad 100644 --- a/app/Exports/UsersExport.php +++ b/app/Exports/UsersExport.php @@ -19,17 +19,17 @@ public function __construct(UserRepository $userRepository) } /** - * @return \Illuminate\Support\Collection - */ + * @return \Illuminate\Support\Collection + */ public function collection() { - $activeUsers = $this->userRepository->getCurrentUsers(['*'],['certificates']); + $activeUsers = $this->userRepository->getCurrentUsers(['*'], ['certificates']); $exportData = []; - foreach ($activeUsers as $user){ + foreach ($activeUsers as $user) { $user->makeHidden(['updated_at', 'lid_af', 'pending_user']); $data = $user->toArray(); $data['certificates'] = $user->getCertificationsAbbreviations(); - array_push($exportData,$data); + array_push($exportData, $data); } return new Collection($exportData); @@ -40,7 +40,7 @@ public function collection() */ public function title(): string { - return trans('user.active_members'); + return 'Active members'; } /** @@ -50,31 +50,31 @@ public function headings(): array { return [ "#", - trans('user.email'), - trans('user.firstname'), - trans('user.preposition'), - trans('user.lastname'), - trans('user.street'), - trans('user.housenumber'), - trans('user.city'), - trans('user.zipcode'), - trans('user.country'), - trans('user.phonenumber'), - trans('user.phonenumber_alt'), - trans('user.emNumber'), - trans('user.emHouseNumber'), - trans('user.emstreet'), - trans('user.emcity'), - trans('user.emzipcode'), - trans('user.emcountry'), - trans('user.birthDay'), - trans('user.kind_of_member'), - trans('user.IBAN'), - trans('user.BIC'), - trans('user.incasso'), - trans('user.remark'), - trans('user.created_at'), - trans('user.certificates'), + 'Email address', + 'First name', + 'Preposition', + 'Last name', + 'Street', + 'House number', + 'City', + 'Postal code', + 'Country', + 'Phone number', + 'Alternative phone number', + 'Emergency phone number', + 'Emergency house number', + 'Emergency street', + 'Emergency city', + 'Emergency postal code', + 'Emergency country', + 'Birthdate', + 'Kind of member', + 'IBAN', + 'BIC', + 'Accept Automatic Collection', + 'Remarks', + 'User created at', + 'Certificates', ]; } } diff --git a/app/Http/Controllers/AgendaItemCategorieController.php b/app/Http/Controllers/AgendaItemCategorieController.php deleted file mode 100644 index 4004a197..00000000 --- a/app/Http/Controllers/AgendaItemCategorieController.php +++ /dev/null @@ -1,83 +0,0 @@ -middleware('auth'); - $this->middleware('authorize:'.\Config::get('constants.Administrator')); - $this->_AgendaItemCategoryRepository = $repositorieFactory->getRepositorie(RepositorieFactory::$AGENDAITEMRECATEGORYPOKEY); - } - - //gives the agendaItemCategory views - public function index(){ - $agendaItemCategories= $this->_AgendaItemCategoryRepository->all(array("id","name")); - return view('beheer.agendaItemCategory.index', compact('agendaItemCategories')); - } - - //show create screen - public function create(){ - $fields = ['title' => trans('agendaItemCategory.add'), - 'method' => 'POST', - 'url' => '/agendaItemCategories',]; - $agendaItemCategory = null; - return view('beheer.agendaItemCategory.create_edit', compact(['fields','agendaItemCategory'])); - } - - //store agendaItemCategory - public function store(Request $request){ - $this->validateInput($request); - $this->_AgendaItemCategoryRepository->create($request->all()); - - \Session::flash("message",trans('agendaItemCategory.added')); - return redirect('/agendaItemCategories'); - } - - public function show(Request $request, AgendaItemCategorie $agendaItemCategory){ - return view('beheer.agendaItemCategory.show', compact('agendaItemCategory')); - } - - //show edit screen - public function edit(Request $request,AgendaItemCategorie $agendaItemCategory){ - $fields = ['title' => trans('agendaItemCategory.edit'), - 'method' => 'PATCH', - 'url' => '/agendaItemCategories/'. $agendaItemCategory->id]; - - return view('beheer.agendaItemCategory.create_edit', compact('fields','agendaItemCategory')); - } - - //update agendaItemCategory - public function update(Request $request,AgendaItemCategorie $agendaItemCategory){ - $this->validateInput($request); - $this->_AgendaItemCategoryRepository->update($agendaItemCategory->id,$request->all()); - - \Session::flash("message",trans('agendaItemCategory.edited')); - return redirect('/agendaItemCategories'); - } - - public function destroy(Request $request, AgendaItemCategorie $agendaItemCategory){ - $this->_AgendaItemCategoryRepository->delete($agendaItemCategory->id); - - \Session::flash("message",trans('agendaItemCategory.deleted')); - return redirect('/agendaItemCategories'); - } - - private function validateInput(Request $request){ - $this->validate($request,[ - 'EN_text' => 'required', - 'NL_text' => 'required', - ]); - } -} diff --git a/app/Http/Controllers/AgendaItemCategoryController.php b/app/Http/Controllers/AgendaItemCategoryController.php new file mode 100644 index 00000000..766672d3 --- /dev/null +++ b/app/Http/Controllers/AgendaItemCategoryController.php @@ -0,0 +1,84 @@ +middleware('auth'); + $this->middleware('authorize:' . Config::get('constants.Administrator')); + + $this->agendaItemCategoryRepository = $agendaItemCategoryRepository; + } + + public function index() + { + $agendaItemCategories = $this->agendaItemCategoryRepository->all(['id', 'name']); + return view('beheer.agendaItemCategory.index', compact('agendaItemCategories')); + } + + public function create() + { + $fields = ['title' => 'Add an event category', + 'method' => 'POST', + 'url' => '/agendaItemCategories']; + $agendaItemCategory = null; + return view('beheer.agendaItemCategory.create_edit', compact(['fields', 'agendaItemCategory'])); + } + + public function store(Request $request) + { + $this->validateInput($request); + $this->agendaItemCategoryRepository->create($request->all()); + + Session::flash("message", 'Events category is added'); + return redirect('/agendaItemCategories'); + } + + public function show(Request $request, AgendaItemCategory $agendaItemCategory) + { + return view('beheer.agendaItemCategory.show', compact('agendaItemCategory')); + } + + public function edit(Request $request, AgendaItemCategory $agendaItemCategory) + { + $fields = ['title' => 'Edit category', + 'method' => 'PATCH', + 'url' => '/agendaItemCategories/' . $agendaItemCategory->id]; + + return view('beheer.agendaItemCategory.create_edit', compact('fields', 'agendaItemCategory')); + } + + public function update(Request $request, AgendaItemCategory $agendaItemCategory) + { + $this->validateInput($request); + $this->agendaItemCategoryRepository->update($agendaItemCategory->id, $request->all()); + + Session::flash("message", 'Events category is edited'); + return redirect('/agendaItemCategories'); + } + + public function destroy(Request $request, AgendaItemCategory $agendaItemCategory) + { + $this->agendaItemCategoryRepository->delete($agendaItemCategory->id); + + Session::flash("message", 'Events category is removed'); + return redirect('/agendaItemCategories'); + } + + private function validateInput(Request $request) + { + $this->validate($request, [ + 'name' => 'required|max:255', + ]); + } +} diff --git a/app/Http/Controllers/AgendaItemController.php b/app/Http/Controllers/AgendaItemController.php index 3ce1b290..ab482a6f 100644 --- a/app/Http/Controllers/AgendaItemController.php +++ b/app/Http/Controllers/AgendaItemController.php @@ -3,203 +3,145 @@ namespace App\Http\Controllers; use App\AgendaItem; +use App\Repositories\AgendaItemCategoryRepository; +use App\Repositories\AgendaItemRepository; use App\Repositories\ApplicationFormRepositories\ApplicationFormRepository; -use App\Repositories\RepositorieFactory; -use Illuminate\Http\RedirectResponse; -use Intervention\Image\ImageManagerStatic as Image; use Illuminate\Http\Request; +use Illuminate\Support\Facades\Session; +use Intervention\Image\ImageManagerStatic as Image; class AgendaItemController extends Controller { - private $_agendaItemRepository; private $_agendaItemCategoryRepository; private $_applicationFormRepository; - /** - * AgendaItemController constructor. - * @param RepositorieFactory $repositorieFactory - * @param ApplicationFormRepository $applicationFormRepository - */ - public function __construct(RepositorieFactory $repositorieFactory, ApplicationFormRepository $applicationFormRepository) - { - $this->_agendaItemRepository = $repositorieFactory->getRepositorie(RepositorieFactory::$AGENDAITEMREPOKEY); - $this->_agendaItemCategoryRepository = $repositorieFactory->getRepositorie(RepositorieFactory::$AGENDAITEMRECATEGORYPOKEY); - $this->_applicationFormRepository = $applicationFormRepository; - + public function __construct( + AgendaItemRepository $agendaItemRepository, + AgendaItemCategoryRepository $agendaItemCategoryRepository, + ApplicationFormRepository $applicationFormRepository + ) { $this->middleware('auth'); - $this->middleware('authorize:'.\Config::get('constants.Content_administrator') .',' . \Config::get('constants.Activity_administrator')); - } + $this->middleware('authorize:' . config('constants.Content_administrator') . ',' . config('constants.Activity_administrator')); + $this->_agendaItemRepository = $agendaItemRepository; + $this->_agendaItemCategoryRepository = $agendaItemCategoryRepository; + $this->_applicationFormRepository = $applicationFormRepository; + } - /** - * Display a listing of the resource. - * - * @return Response - */ public function index() { return view('beheer.agendaItem.index'); } - /** - * Show the form for creating a new resource. - * - * @return Response - */ public function create() { - $fields = [ - 'title_info' => trans('AgendaItems.info'), - 'title_content' => trans('AgendaItems.content'), - 'title_image' => trans('AgendaItems.imagePage'), - 'title' => trans('AgendaItems.add'), - 'method' => 'POST', - 'url' => '/agendaItems',]; - - $agendaItem = null; - $agendaItemCategories = array(); - $applicationForms = array(); - - foreach ($this->_agendaItemCategoryRepository->all(array('id','name')) as $category){ - $agendaItemCategories[$category->id] = $category->categorieName->text(); - } - - foreach ($this->_applicationFormRepository->all(array('id','name')) as $form){ - $applicationForms[$form->id] = $form->applicationFormName->text(); - } - - return view('beheer.agendaItem.create_edit',compact(['fields','agendaItem','agendaItemCategories','applicationForms'])); + $fields = $this->getFields('POST', '/agendaItems', 'Add an event'); + return $this->renderCreateEditView(null, $fields); } - /** - * Store a newly created resource in storage. - * - * @return Response - */ - public function store(Request $request){ + public function store(Request $request) + { $this->validateInput($request); $agendaItem = $this->_agendaItemRepository->create($request->all()); - - //save image - if($request->hasFile('thumbnail')){ - $name = $agendaItem->id . '-thumbnail.' . $request->thumbnail->extension(); - $request->file('thumbnail')->storeAs('agendaItem', $name,'public'); - $agendaItem->image_url = 'agendaItem/' . $name; - $agendaItem->save(); - - //resize image - $img_path = "../storage/app/public/" . $agendaItem->image_url; - Image::make($img_path)->fit(400, 300)->save($img_path); - } - - \Session::flash("message",trans('AgendaItems.added')); + $this->handleImage($request, $agendaItem); + Session::flash("message", 'Event added'); return redirect('/agendaItems'); } - /** - * Display the specified resource. - * - * @param int $id - * @return Response - */ public function show(AgendaItem $agendaItem) { return view('beheer.agendaItem.show', compact('agendaItem')); } - /** - * Show the form for editing the specified resource. - * - * @param int $id - * @return Response - */ public function edit(AgendaItem $agendaItem) { - $fields = [ - 'title_info' => trans('AgendaItems.info'), - 'title_content' => trans('AgendaItems.content'), - 'title_image' => trans('AgendaItems.imagePage'), - 'title' => trans('AgendaItems.edit'), - 'method' => 'PATCH', - 'url' => '/agendaItems/' . $agendaItem->id]; - - $agendaItemCategories = array(); - $applicationForms = array(); - - foreach ($this->_agendaItemCategoryRepository->all(array('id','name')) as $category){ - $agendaItemCategories[$category->id] = $category->categorieName->text(); - } - - foreach ($this->_applicationFormRepository->all(array('id','name')) as $form){ - $applicationForms[$form->id] = $form->applicationFormName->text(); - } - - return view('beheer.agendaItem.create_edit',compact(['fields','agendaItem','agendaItemCategories','applicationForms'])); + $fields = $this->getFields('PATCH', '/agendaItems/' . $agendaItem->id, 'Edit event'); + return $this->renderCreateEditView($agendaItem, $fields); } - /** - * Update the specified resource in storage. - * - * @param int $id - * @return Response - */ public function update(Request $request, AgendaItem $agendaItem) { $this->validateInput($request); $this->_agendaItemRepository->update($agendaItem->id, $request->all()); - - //save image - if($request->hasFile('thumbnail')){ - $name = $agendaItem->id . '-thumbnail.' . $request->thumbnail->extension(); - $request->file('thumbnail')->storeAs('agendaItem', $name,'public'); - $agendaItem->image_url = 'agendaItem/' . $name; - $agendaItem->save(); - - //resize image - $img_path = "../storage/app/public/" . $agendaItem->image_url; - Image::make($img_path)->fit(400, 300)->save($img_path); - } - - \Session::flash("message",trans('AgendaItems.edited')); + $this->handleImage($request, $agendaItem); + Session::flash("message", 'Event edited'); return redirect('/agendaItems'); } - /** - * Remove the specified resource from storage. - * - * @param int $id - * @return Response - */ public function destroy($id) { $this->_agendaItemRepository->delete($id); - - \Session::flash("message",trans('AgendaItems.deleted')); + Session::flash("message", 'Event removed'); return redirect('/agendaItems'); } - /** - * @param AgendaItem $agendaItem - * @return RedirectResponse - */ - public function copy(AgendaItem $agendaItem): RedirectResponse + public function copy(AgendaItem $agendaItem) { $newAgendaItem = $this->_agendaItemRepository->copy($agendaItem); - return redirect('/agendaItems/' . $newAgendaItem->id . '/edit'); } - private function validateInput(Request $request){ - $this->validate($request,[ - 'NL_title' => 'required', - 'EN_title' => 'required', - 'NL_text' => 'required', - 'EN_text' => 'required', + private function validateInput(Request $request) + { + $this->validate($request, [ + 'title' => 'required|max:255', + 'shortDescription' => 'required|max:100', + 'text' => 'required', + 'thumbnail' => 'image|mimes:jpeg,png,jpg', 'category' => 'required|numeric|min:1', 'applicationForm' => 'required|numeric|min:0', 'endDate' => 'required|date', 'startDate' => 'required|date', ]); } + + private function getFields($method, $url, $title) + { + return [ + 'title_info' => 'Event general information', + 'title_content' => 'Event item content', + 'title_image' => 'Event item thumbnail', + 'title' => $title, + 'method' => $method, + 'url' => $url, + ]; + } + + private function renderCreateEditView($agendaItem, $fields) + { + $agendaItemCategories = $this->getCategories(); + $applicationForms = $this->getForms(); + return view('beheer.agendaItem.create_edit', compact(['fields', 'agendaItem', 'agendaItemCategories', 'applicationForms'])); + } + + private function getCategories() + { + $categories = []; + foreach ($this->_agendaItemCategoryRepository->all(['id', 'name']) as $category) { + $categories[$category->id] = $category->name; + } + return $categories; + } + + private function getForms() + { + $forms = []; + foreach ($this->_applicationFormRepository->all(['id', 'name']) as $form) { + $forms[$form->id] = $form->name; + } + return $forms; + } + + private function handleImage(Request $request, AgendaItem $agendaItem) + { + if ($request->hasFile('thumbnail')) { + $name = $agendaItem->id . '-thumbnail.' . $request->thumbnail->extension(); + $request->file('thumbnail')->storeAs('agendaItem', $name, 'public'); + $agendaItem->image_url = 'agendaItem/' . $name; + $agendaItem->save(); + $img_path = "../storage/app/public/" . $agendaItem->image_url; + Image::make($img_path)->fit(400, 300)->save($img_path); + } + } } diff --git a/app/Http/Controllers/Api/AgendaController.php b/app/Http/Controllers/Api/AgendaController.php index 4ee35b37..4c9d8a63 100644 --- a/app/Http/Controllers/Api/AgendaController.php +++ b/app/Http/Controllers/Api/AgendaController.php @@ -3,35 +3,32 @@ namespace App\Http\Controllers\Api; use App\AgendaItem; -use App\AgendaItemCategorie; +use App\AgendaItemCategory; use App\Http\Controllers\Controller; use App\Services\AgendaApplicationFormService; -use Auth; use Carbon\Carbon; use Illuminate\Http\Request; -use Illuminate\Support\Facades\App; +use Illuminate\Support\Facades\Auth; class AgendaController extends Controller { public function getAgenda(Request $request) { $agendaItemQuery = AgendaItem::with([ - 'agendaItemShortDescription', 'getApplicationForm', - 'getApplicationFormResponses', - 'agendaItemCategory.categorieName' + 'agendaItemCategory', ]); - + // Set limit and page - $limit = $request->has('limit')? $request->get('limit'): 9; - $start = $request->has('start')? $request->get('start') : 0; - + $limit = $request->has('limit') ? $request->get('limit') : 9; + $start = $request->has('start') ? $request->get('start') : 0; + // Apply filters $category = $request->input('category'); if ($category) { $agendaItemQuery->where('category', intval($category)); } - + $startDate = $request->input('startDate'); if ($startDate) { $startDate = Carbon::createFromFormat('d-m-Y', $startDate)->startOfDay(); @@ -40,18 +37,18 @@ public function getAgenda(Request $request) ->orWhere('endDate', '>=', $startDate); }); } - + $endDate = $request->input('endDate'); if ($endDate) { $endDate = Carbon::createFromFormat('d-m-Y', $endDate)->startOfDay(); $agendaItemQuery->where('startDate', '<=', $endDate); } - + $agendaItemQuery->orderBy('startDate', 'asc'); - + // Get total count for pagination $agendaItemCount = $agendaItemQuery->count(); - + // Get paginated agenda items $agendaItems = $agendaItemQuery ->skip($start) @@ -60,47 +57,46 @@ public function getAgenda(Request $request) ->map(function ($agendaItem) { $agendaApplicationFormService = new AgendaApplicationFormService(); $currentUserSignedUp = false; - + $registeredUserIds = []; + if ($agendaItem->application_form_id && $agendaItem->canRegister()) { $registeredUserIds = $agendaApplicationFormService->getRegisteredUserIds($agendaItem); $currentUserSignedUp = in_array(Auth::id(), $registeredUserIds); } - + return [ 'id' => $agendaItem->id, - 'title' => $agendaItem->agendaItemTitle->text(), + 'title' => $agendaItem->title, 'thumbnail' => $agendaItem->getImageUrl(), 'startDate' => Carbon::parse($agendaItem->startDate)->format('d M'), 'endDate' => $agendaItem->endDate, 'full_startDate' => $agendaItem->startDate, - 'category' => $agendaItem->agendaItemCategory->categorieName->text(), - 'text' => $agendaItem->agendaItemShortDescription->text(), + 'category' => $agendaItem->agendaItemCategory->name, + 'text' => $agendaItem->shortDescription, 'formId' => $agendaItem->getApplicationForm, 'canRegister' => $agendaItem->canRegister(), 'application_form_id' => $agendaItem->application_form_id, - 'amountOfPeopleRegisterd' => count($agendaItem->getApplicationFormResponses), + 'amountOfPeopleRegisterd' => count($registeredUserIds), 'currentUserSignedUp' => $currentUserSignedUp, ]; }); - + return [ 'agendaItemCount' => $agendaItemCount, 'agendaItems' => $agendaItems, ]; } - - - public function getCategories(){ - $categories = AgendaItemCategorie::with('categorieName') - ->get() + public function getCategories() + { + $categories = AgendaItemCategory::all() ->map(function ($category) { return [ 'id' => $category->id, - 'name' => $category->categorieName->text() + 'name' => $category->name, ]; }); - + return response()->json($categories); } } diff --git a/app/Http/Controllers/Api/RegistrationController.php b/app/Http/Controllers/Api/RegistrationController.php index 9356f165..2c7c8e23 100644 --- a/app/Http/Controllers/Api/RegistrationController.php +++ b/app/Http/Controllers/Api/RegistrationController.php @@ -7,6 +7,7 @@ use Carbon\Carbon; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; +use Illuminate\Support\Facades\Config; class RegistrationController extends Controller { @@ -15,11 +16,12 @@ public function __construct() $this->middleware('auth'); } - public function registrationsByUser(Request $request){ - $userId = $request->get('user_id',-1); + public function registrationsByUser(Request $request) + { + $userId = $request->get('user_id', -1); - if(!Auth::user()->hasRole(\Config::get('constants.Administrator'))){ - if(Auth::user()->id != $userId){ + if (!Auth::user()->hasRole(Config::get('constants.Administrator'))) { + if (Auth::user()->id != $userId) { abort(401); } } @@ -28,20 +30,19 @@ public function registrationsByUser(Request $request){ ->with([ 'applicationResponses', 'applicationResponses.agendaItem', - 'applicationResponses.agendaItem.agendaItemTitle' ]) ->find($userId); $registrations = []; - if($user != null){ - foreach ($user->applicationResponses as $applicationRespons){ - array_push($registrations,[ - 'name' => $applicationRespons->agendaItem->agendaItemTitle->text(), + if ($user != null) { + foreach ($user->applicationResponses as $applicationRespons) { + array_push($registrations, [ + 'name' => $applicationRespons->agendaItem->title, 'startDate' => Carbon::parse($applicationRespons->agendaItem->startDate)->format('d-m-Y H:i'), 'actions' => ' - - - ' + + + ', ]); } } diff --git a/app/Http/Controllers/Api/UserController.php b/app/Http/Controllers/Api/UserController.php index 93a4aa01..97a7faeb 100644 --- a/app/Http/Controllers/Api/UserController.php +++ b/app/Http/Controllers/Api/UserController.php @@ -2,11 +2,11 @@ namespace App\Http\Controllers\Api; +use App\Http\Controllers\Controller; use App\User; use Illuminate\Database\Eloquent\Builder; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; -use App\Http\Controllers\Controller; class UserController extends Controller { @@ -20,8 +20,8 @@ public function autoComplete(Request $request): JsonResponse $users = User::query() ->where(function (Builder $query) use ($request) { $term = $request->get('term', ''); - $query->where('firstname', 'like' , "%$term%") - ->orWhere('lastname', 'like' , "%$term%"); + $query->where('firstname', 'like', "%$term%") + ->orWhere('lastname', 'like', "%$term%"); }) ->selectRaw("CONCAT(firstname, ' ', lastname) as text") ->get(); diff --git a/app/Http/Controllers/Api/ZekeringController.php b/app/Http/Controllers/Api/ZekeringController.php index ccf63b50..64afa7b4 100644 --- a/app/Http/Controllers/Api/ZekeringController.php +++ b/app/Http/Controllers/Api/ZekeringController.php @@ -3,63 +3,60 @@ namespace App\Http\Controllers\Api; use App\Http\Controllers\Controller; -use App\Repositories\RepositorieFactory; use App\Repositories\ZekeringenRepository; -use App\Zekering; use Illuminate\Http\Request; +use Illuminate\Support\Facades\Config; class ZekeringController extends Controller { public function __construct() { $this->middleware('auth'); - $this->middleware('authorize:'.\Config::get('constants.Activity_administrator'))->only('destroy'); + $this->middleware('authorize:' . Config::get('constants.Activity_administrator'))->only('destroy'); } - public function getZekeringen(Request $request, RepositorieFactory $repositorieFactory) { - $zekeringenRepo = $repositorieFactory->getRepositorie($repositorieFactory::$ZEKERINGENREPOKEY); - - $zekeringen = $zekeringenRepo->findBy('has_parent',false)->with('children')->get(); - - return [ - "zekeringen" => $zekeringen - ]; + public function getZekeringen(ZekeringenRepository $zekeringenRepository) + { + $zekeringen = $zekeringenRepository->findBy('has_parent', false)->with('children')->get(); + + return ['zekeringen' => $zekeringen]; } - public function storeZekering(Request $request,ZekeringenRepository $zekeringenRepository){ + public function storeZekering(Request $request, ZekeringenRepository $zekeringenRepository) + { $this->validateInput($request); + $zekeringenRepository->create($request->all()); return redirect('/zekeringen'); } - public function storeSubZekering(Request $request,ZekeringenRepository $zekeringenRepository){ + public function storeSubZekering(Request $request, ZekeringenRepository $zekeringenRepository) + { $this->validateInput($request); + $data = $request->all(); $data['parent'] = $request->get('parent_id'); $zekeringenRepository->create($data); - return response(["msg" => "Sub zekering created"],200); + return response(["msg" => "Sub zekering created"], 200); } - /** - * Remove the specified resource from storage. - * - * @param int $id - * @return \Illuminate\Http\Response - */ - public function destroy($id, RepositorieFactory $repositorieFactory) + public function destroy(int $id, ZekeringenRepository $zekeringenRepository) { - $zekeringenRepo = $repositorieFactory->getRepositorie($repositorieFactory::$ZEKERINGENREPOKEY); - $zekeringenRepo->delete($id); + $zekeringenRepository->delete($id); - return response("",200); + return response("", 200); } - private function validateInput(Request $request){ - $this->validate($request,[ - 'text' => 'required' - ]); + private function validateInput(Request $request) + { + $request->validate($this->getValidationRules()); + } + + private function getValidationRules() + { + return ['text' => 'required']; } } diff --git a/app/Http/Controllers/ApiController.php b/app/Http/Controllers/ApiController.php index 9dca40d2..bf547a2a 100644 --- a/app/Http/Controllers/ApiController.php +++ b/app/Http/Controllers/ApiController.php @@ -2,24 +2,22 @@ namespace App\Http\Controllers; -use App\AgendaItem; use App\MenuItem; -use App\Repositories\RepositorieFactory; use App\User; -use Carbon\Carbon; use Illuminate\Http\Request; class ApiController extends Controller { public function __construct() { - $this->middleware('auth')->except('getAgenda','getZekeringen'); + $this->middleware('auth')->except('getAgenda', 'getZekeringen'); } - public function getMenuItems(Request $request){ + public function getMenuItems(Request $request) + { $menuItemQeury = MenuItem::query(); - if($request->has('type')) { - if($request->get('type') === "subItem"){ + if ($request->has('type')) { + if ($request->get('type') === "subItem") { $menuItemQeury->where('parent_id', '=', intval($request->get('parentId'))); } else { $menuItemQeury->where('parent_id', '=', null); @@ -27,24 +25,23 @@ public function getMenuItems(Request $request){ } $entries = $menuItemQeury->get(); $menuItems = array(); - foreach ($entries as $menuItem){ + foreach ($entries as $menuItem) { array_push($menuItems, [ - "id" => $menuItem->id, - "name" => $menuItem->text->text() + "id" => $menuItem->id, + "name" => $menuItem->name, ]); } return $menuItems; } - - - public function getUsers(){ + public function getUsers() + { $users = array(); - foreach (User::all() as $user){ - array_push($users,[ - 'id' => $user->id, - 'name' => $user->getName(), + foreach (User::all() as $user) { + array_push($users, [ + 'id' => $user->id, + 'name' => $user->getName(), 'email' => $user->email, ]); } diff --git a/app/Http/Controllers/ApplicationForm/AgendaApplicationFormController.php b/app/Http/Controllers/ApplicationForm/AgendaApplicationFormController.php index c4719ddf..27050962 100644 --- a/app/Http/Controllers/ApplicationForm/AgendaApplicationFormController.php +++ b/app/Http/Controllers/ApplicationForm/AgendaApplicationFormController.php @@ -4,17 +4,17 @@ use App\AgendaItem; use App\Exports\AgendaRegistrationExport; +use App\Http\Controllers\Controller; use App\Http\Resources\ApplicationFormRowVueResource; use App\Models\ApplicationForm\ApplicationResponse; use App\Repositories\ApplicationFormRepositories\ApplicationFormRegistrationRepository; -use App\Repositories\InschrijvenRepository; use App\Repositories\UserRepository; use App\Services\AgendaApplicationFormService; -use App\Http\Controllers\Controller; use App\User; -use Auth; use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; +use Illuminate\Support\Facades\Auth; +use Illuminate\Support\Facades\Config; use Illuminate\View\View; use Maatwebsite\Excel\Facades\Excel; use Symfony\Component\HttpFoundation\BinaryFileResponse; @@ -27,7 +27,7 @@ class AgendaApplicationFormController extends Controller public function __construct() { $this->middleware('auth'); - $this->middleware('authorize:' . \Config::get('constants.Content_administrator') . ',' . \Config::get('constants.Activity_administrator'))->except('destroy'); + $this->middleware('authorize:' . Config::get('constants.Content_administrator') . ',' . Config::get('constants.Activity_administrator'))->except('destroy'); } /** @@ -37,7 +37,7 @@ public function __construct() */ public function index(AgendaItem $agendaItem, AgendaApplicationFormService $agendaApplicationFormService): View { - $users = $agendaApplicationFormService->getRegisteredUsers($agendaItem); + $users = $agendaApplicationFormService->getRegisteredUsers($agendaItem); $agendaId = $agendaItem->id; return view("forms.inschrijven_show", compact('users', 'agendaId')); @@ -47,8 +47,8 @@ public function registerUser(AgendaItem $agendaItem, UserRepository $userReposit { //retrieves all the rows of the form $applicationForm = $agendaItem->getApplicationForm; - $rows = ApplicationFormRowVueResource::collection($applicationForm->applicationFormRows); - $users = []; + $rows = ApplicationFormRowVueResource::collection($applicationForm->applicationFormRows); + $users = []; $registeredUsers = []; foreach ($agendaItem->getApplicationFormResponses as $registeredUser) { @@ -88,7 +88,7 @@ public function saveRegistration( public function show(User $user, AgendaItem $agendaItem, ApplicationFormRegistrationRepository $repository): View { $applicationDataRows = $repository->getApplicationInformation($agendaItem->id, $user->id); - $agendaId = $agendaItem->id; + $agendaId = $agendaItem->id; return view('forms.inschrijven_details', compact('agendaId', 'applicationDataRows')); } @@ -103,7 +103,7 @@ public function show(User $user, AgendaItem $agendaItem, ApplicationFormRegistra public function destroy($Agenda_id, $applicationResponseId): RedirectResponse { $applicationReponse = ApplicationResponse::find($applicationResponseId); - if (!Auth::user()->hasRole(\Config::get('constants.Activity_administrator'))) { + if (!Auth::user()->hasRole(Config::get('constants.Activity_administrator'))) { if (Auth::user()->id != $applicationReponse->user_id) { abort(401); } @@ -125,7 +125,7 @@ public function exportData(int $agendaId, AgendaApplicationFormService $agendaAp $agendaItem = AgendaItem::findOrFail($agendaId); return Excel::download( new AgendaRegistrationExport($agendaApplicationFormService, $agendaItem), - preg_replace('/[^a-zA-Z0-9]+/', '-', $agendaItem->agendaItemTitle->text()) . '.xlsx' + preg_replace('/[^a-zA-Z0-9]+/', '-', $agendaItem->title) . '.xlsx' ); } diff --git a/app/Http/Controllers/ApplicationForm/ApplicationFormController.php b/app/Http/Controllers/ApplicationForm/ApplicationFormController.php index 3d951d54..26c05067 100644 --- a/app/Http/Controllers/ApplicationForm/ApplicationFormController.php +++ b/app/Http/Controllers/ApplicationForm/ApplicationFormController.php @@ -2,16 +2,15 @@ namespace App\Http\Controllers\ApplicationForm; +use App\Http\Controllers\Controller; use App\Http\Requests\ApplicationFormStoreRequest; use App\Http\Resources\ApplicationFormRowVueResource; use App\Models\ApplicationForm\ApplicationForm; use App\Repositories\ApplicationFormRepositories\ApplicationFormRepository; -use App\Repositories\RepositorieFactory; use Illuminate\Http\RedirectResponse; -use Illuminate\Http\Request; -use App\Http\Controllers\Controller; +use Illuminate\Support\Facades\Config; +use Illuminate\Support\Facades\Session; use Illuminate\View\View; -use Session; class ApplicationFormController extends Controller { @@ -22,7 +21,7 @@ class ApplicationFormController extends Controller */ public function __construct() { - $this->middleware('authorize:' . \Config::get('constants.Content_administrator') . ',' . \Config::get('constants.Activity_administrator')); + $this->middleware('authorize:' . Config::get('constants.Content_administrator') . ',' . Config::get('constants.Activity_administrator')); } /** @@ -33,12 +32,11 @@ public function __construct() public function index(): View { $applicationForms = ApplicationForm::query() - ->with('applicationFormName') ->get(); return view('beheer.applicationForm.index') ->with([ - 'applicationForms' => $applicationForms + 'applicationForms' => $applicationForms, ]); } @@ -50,16 +48,16 @@ public function index(): View public function create(): View { $fields = [ - 'title' => trans('ApplicationForm.add'), + 'title' => 'Add an application form', 'method' => 'POST', - 'url' => route('beheer.applicationForms.store') + 'url' => route('beheer.applicationForms.store'), ]; return view('beheer.applicationForm.create_edit') ->with([ - 'fields' => $fields, + 'fields' => $fields, 'applicationForm' => null, - 'rows' => [], + 'rows' => [], ]); } @@ -76,7 +74,7 @@ public function store( ): RedirectResponse { $applicationFormRepository->create($request->all()); - Session::flash("message", trans('ApplicationForm.added')); + Session::flash("message", 'Application form added'); return redirect()->route('beheer.applicationForms.index'); } @@ -103,16 +101,16 @@ public function show(ApplicationForm $applicationForm): View public function edit(ApplicationForm $applicationForm): View { $fields = [ - 'title' => trans('ApplicationForm.add'), + 'title' => 'Add an application form', 'method' => 'PUT', - 'url' => route('beheer.applicationForms.update', $applicationForm->id) + 'url' => route('beheer.applicationForms.update', $applicationForm->id), ]; return view('beheer.applicationForm.create_edit') ->with([ - 'fields' => $fields, + 'fields' => $fields, 'applicationForm' => $applicationForm, - 'rows' => ApplicationFormRowVueResource::collection($applicationForm->applicationFormRows), + 'rows' => ApplicationFormRowVueResource::collection($applicationForm->applicationFormRows), ]); } @@ -131,7 +129,7 @@ public function update( ): RedirectResponse { $applicationFormRepository->update($id, $request->all()); - Session::flash("message", trans('ApplicationForm.edited')); + Session::flash("message", 'Application form edited'); return redirect()->route('beheer.applicationForms.index'); } @@ -146,7 +144,7 @@ public function destroy(int $id, ApplicationFormRepository $applicationFormRepos { $applicationFormRepository->delete($id); - Session::flash("message", trans('ApplicationForm.edited')); + Session::flash("message", 'Application form edited'); return redirect()->route('beheer.applicationForms.index'); } } diff --git a/app/Http/Controllers/ApplicationForm/UserApplicationFormController.php b/app/Http/Controllers/ApplicationForm/UserApplicationFormController.php index 00e8ab18..2edd7de4 100644 --- a/app/Http/Controllers/ApplicationForm/UserApplicationFormController.php +++ b/app/Http/Controllers/ApplicationForm/UserApplicationFormController.php @@ -3,16 +3,14 @@ namespace App\Http\Controllers\ApplicationForm; use App\AgendaItem; +use App\Http\Controllers\Controller; use App\Http\Resources\ApplicationFormRowVueResource; -use App\Models\ApplicationForm\ApplicationFormRow; use App\Models\ApplicationForm\ApplicationResponse; -use App\Notifications\AgendaSubscribed; use App\Repositories\ApplicationFormRepositories\ApplicationFormRegistrationRepository; -use Auth; use Carbon\Carbon; use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; -use App\Http\Controllers\Controller; +use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Session; class UserApplicationFormController extends Controller @@ -22,21 +20,15 @@ public function __construct() $this->middleware('auth'); } - /** - * Show the form for creating a new resource. - * - * @param AgendaItem $agendaItem - * @return \Illuminate\Http\Response - */ public function showRegistrationForm(AgendaItem $agendaItem) { $user_id = Auth::user()->id; //check if the date has expired $agendaEndDate = new \DateTime($agendaItem->subscription_endDate); - $now = new \DateTime(); + $now = new \DateTime(); if ($agendaEndDate < $now) { - $error = trans("forms.signupexpired"); + $error = 'The registration date has expired, so you can no longer subscribe.'; $curPageName = $error; return view("forms.inschrijven_error", compact('error', 'curPageName')); @@ -44,7 +36,7 @@ public function showRegistrationForm(AgendaItem $agendaItem) $applicationForm = $agendaItem->getApplicationForm; if ($applicationForm == null) { - $error = trans("forms.form_not_available"); + $error = 'ERROR: No registration form available for this activity.'; $curPageName = $error; return view("forms.inschrijven_error", compact('error', 'curPageName')); @@ -57,18 +49,18 @@ public function showRegistrationForm(AgendaItem $agendaItem) ->first(); if ($signup != null) { - $error = trans("forms.duplicatesignup"); + $error = 'You have already signed up for this event.'; $curPageName = $error; return view("forms.inschrijven_error", compact('error', 'curPageName')); } //retrieves all the rows of the form - $rows = ApplicationFormRowVueResource::collection($applicationForm->applicationFormRows); - $route = 'forms/' . $agendaItem->id; //route for the form sign up + $rows = ApplicationFormRowVueResource::collection($applicationForm->applicationFormRows); + $route = 'forms/' . $agendaItem->id; //route for the form sign up $cancleRoute = 'agenda/' . $agendaItem->id; //route for the form sign up - $curPageName = $applicationForm->applicationFormName->text(); + $curPageName = $applicationForm->name; return view( "forms.inschrijven", @@ -76,14 +68,6 @@ public function showRegistrationForm(AgendaItem $agendaItem) ); } - /** - * Store a newly created resource in storage. - * - * @param \Illuminate\Http\Request $request - * @param AgendaItem $agendaItem - * @param ApplicationFormRegistrationRepository $repository - * @return \Illuminate\Http\Response - */ public function store(Request $request, AgendaItem $agendaItem, ApplicationFormRegistrationRepository $repository) { //check if the user has already signed up @@ -93,7 +77,7 @@ public function store(Request $request, AgendaItem $agendaItem, ApplicationFormR ->first(); if ($signup != null) { - $error = trans("forms.duplicatesignup"); + $error = 'You have already signed up for this event.'; $curPageName = $error; return view("forms.inschrijven_error", compact('menu', 'error', 'curPageName')); @@ -105,15 +89,10 @@ public function store(Request $request, AgendaItem $agendaItem, ApplicationFormR return redirect('agenda/' . $agendaItem->id); } - /** - * @param AgendaItem $agendaItem - * @param int $fromAgendaItem - * @return RedirectResponse - */ public function unregister(AgendaItem $agendaItem, int $fromAgendaItem = 1): RedirectResponse { if (Carbon::parse($agendaItem->subscription_endDate) < Carbon::now()) { - Session::flash("message", trans('ApplicationForm.subscriptionDatePastUnregisterFailed')); + Session::flash("message", 'The registration date has expired, so you can no longer unsubscribe.'); if ($fromAgendaItem == 1) { return redirect('agenda/' . $agendaItem->id); @@ -127,11 +106,11 @@ public function unregister(AgendaItem $agendaItem, int $fromAgendaItem = 1): Red ->where('user_id', Auth::user()->id) ->delete(); - Session::flash("message", trans('ApplicationForm.userUnregisterd')); + Session::flash("message", 'You successfully unsubscribed from the event.'); if ($fromAgendaItem == 1) { return redirect('agenda/' . $agendaItem->id); - } else if ($fromAgendaItem == 0) { + } else { return redirect('agenda/'); } } diff --git a/app/Http/Controllers/Auth/ForgotPasswordController.php b/app/Http/Controllers/Auth/ForgotPasswordController.php index 27899d43..91c9ec4e 100644 --- a/app/Http/Controllers/Auth/ForgotPasswordController.php +++ b/app/Http/Controllers/Auth/ForgotPasswordController.php @@ -17,7 +17,7 @@ class ForgotPasswordController extends Controller | includes a trait which assists in sending these notifications from | your application to your users. Feel free to explore this trait. | - */ + */ use SendsPasswordResetEmails; @@ -42,6 +42,6 @@ public function __construct(MenuSingleton $menuSingleton) public function showLinkRequestForm() { $menu = $this->_menu; - return view('auth.passwords.email',compact('menu')); + return view('auth.passwords.email', compact('menu')); } } diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index 3a7a8bbd..60a4a095 100644 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -4,7 +4,6 @@ use App\CustomClasses\MenuSingleton; use App\Http\Controllers\Controller; -use App\Repositories\RepositorieFactory; use App\Repositories\UserRepository; use Illuminate\Foundation\Auth\AuthenticatesUsers; use Illuminate\Http\Request; @@ -20,7 +19,7 @@ class LoginController extends Controller | redirecting them to your home screen. The controller uses a trait | to conveniently provide its functionality to your applications. | - */ + */ use AuthenticatesUsers; @@ -59,7 +58,7 @@ public function showLoginForm() * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ - public function login(Request $request,UserRepository $userRepository) + public function login(Request $request, UserRepository $userRepository) { $this->validateLogin($request); @@ -72,20 +71,19 @@ public function login(Request $request,UserRepository $userRepository) return $this->sendLockoutResponse($request); } - $users = $userRepository->findBy("email",$request[$this->username()]); + $users = $userRepository->findBy("email", $request[$this->username()]); $user = null; - if(count($users) != 0){ + if (count($users) != 0) { $user = $users[0]; } - if($user != null && $user->isOldMember()){ + if ($user != null && $user->isOldMember()) { return redirect()->back() ->withInput($request->only($this->username(), 'remember')) - ->withErrors([$this->username() => trans('validation.oldUserLogin')]); - } - else if($user != null && $user->isPendingMember()){ + ->withErrors([$this->username() => 'Old members can not login']); + } else if ($user != null && $user->isPendingMember()) { return redirect()->back() ->withInput($request->only($this->username(), 'remember')) - ->withErrors([$this->username() => trans('validation.pendingUserLogin')]); + ->withErrors([$this->username() => 'Pending members can not login']); } if ($this->attemptLogin($request)) { diff --git a/app/Http/Controllers/Auth/ResetPasswordController.php b/app/Http/Controllers/Auth/ResetPasswordController.php index 1dc26683..b442c5bc 100644 --- a/app/Http/Controllers/Auth/ResetPasswordController.php +++ b/app/Http/Controllers/Auth/ResetPasswordController.php @@ -18,7 +18,7 @@ class ResetPasswordController extends Controller | and uses a simple trait to include this behavior. You're free to | explore this trait and override any methods you wish to tweak. | - */ + */ use ResetsPasswords; @@ -53,7 +53,7 @@ public function __construct(MenuSingleton $menuSingleton) public function showResetForm(Request $request, $token = null) { $menu = $this->_menu; - return view('auth.passwords.reset',compact('menu'))->with( + return view('auth.passwords.reset', compact('menu'))->with( ['token' => $token, 'email' => $request->email] ); } diff --git a/app/Http/Controllers/CertificateController.php b/app/Http/Controllers/CertificateController.php index 800ec5f2..9b18ad11 100644 --- a/app/Http/Controllers/CertificateController.php +++ b/app/Http/Controllers/CertificateController.php @@ -3,125 +3,83 @@ namespace App\Http\Controllers; use App\Certificate; -use App\Repositories\RepositorieFactory; +use App\Repositories\CertificateRepository; use Illuminate\Http\Request; +use Illuminate\Support\Facades\Config; +use Illuminate\Support\Facades\Session; class CertificateController extends Controller { private $_certificateRepository; - public function __construct(RepositorieFactory $repositorieFactory) + public function __construct(CertificateRepository $certificateRepository) { - $this->_certificateRepository = $repositorieFactory->getRepositorie(RepositorieFactory::$CERTIFICATEREPOKEY); $this->middleware('auth'); - $this->middleware('authorize:'.\Config::get('constants.Administrator') .',' . \Config::get('constants.Certificate_administrator')); + $this->middleware('authorize:' . Config::get('constants.Administrator') . ',' . Config::get('constants.Certificate_administrator')); + + $this->_certificateRepository = $certificateRepository; } - /** - * Display a listing of the resource. - * - * @return \Illuminate\Http\Response - */ public function index() { - $certificates = $this->_certificateRepository->all(array("id","name")); - + $certificates = $this->_certificateRepository->all(array("id", "name")); return view("beheer.certificate.index", compact("certificates")); } - /** - * Show the form for creating a new resource. - * - * @return \Illuminate\Http\Response - */ public function create() { - $fields = ['title' => trans('certificate.add'), + $fields = ['title' => 'Add a new certificate', 'method' => 'POST', - 'url' => '/certificates',]; + 'url' => '/certificates']; $certificate = null; - return view("beheer.certificate.create_edit", compact('certificate','fields')); + return view("beheer.certificate.create_edit", compact('certificate', 'fields')); } - /** - * Store a newly created resource in storage. - * - * @param \Illuminate\Http\Request $request - * @return \Illuminate\Http\Response - */ public function store(Request $request) { $this->validateData($request); - $this->_certificateRepository->create($request->all()); - \Session::flash("message", trans('certificate.added')); + Session::flash("message", 'Certificate added'); return redirect('/certificates'); } - /** - * Display the specified resource. - * - * @param int $id - * @return \Illuminate\Http\Response - */ public function show(Certificate $certificate) { return view('beheer.certificate.show', compact('certificate')); } - /** - * Show the form for editing the specified resource. - * - * @param int $id - * @return \Illuminate\Http\Response - */ public function edit(Certificate $certificate) { - $fields = ['title' => trans('certificate.add'), + $fields = ['title' => 'Add a new certificate', 'method' => 'PATCH', - 'url' => '/certificates/' . $certificate->id,]; + 'url' => '/certificates/' . $certificate->id]; - return view("beheer.certificate.create_edit", compact('certificate','fields')); + return view("beheer.certificate.create_edit", compact('certificate', 'fields')); } - /** - * Update the specified resource in storage. - * - * @param \Illuminate\Http\Request $request - * @param int $id - * @return \Illuminate\Http\Response - */ public function update(Request $request, Certificate $certificate) { $this->validateData($request); - $this->_certificateRepository->update($certificate->id, $request->all()); - \Session::flash("message", trans('certificate.edited')); + Session::flash("message", 'Certificate edited'); return redirect('/certificates'); } - /** - * Remove the specified resource from storage. - * - * @param int $id - * @return \Illuminate\Http\Response - */ public function destroy(Certificate $certificate) { $this->_certificateRepository->delete($certificate->id); - \Session::flash("message", trans('certificate.deleted')); + Session::flash("message", 'Certificate removed'); return redirect('/certificates'); } - private function validateData(Request $reqeust){ - $this->validate($reqeust,[ - 'duration' => 'numeric|min:0', - 'EN_text' => 'required', - 'NL_text' => 'required', - 'abbreviation' => 'required', + private function validateData(Request $reqeust) + { + $this->validate($reqeust, [ + 'name' => 'required|max:255', + 'abbreviation' => 'required|max:255', ]); } } diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php index 03e02a23..a0a2a8a3 100644 --- a/app/Http/Controllers/Controller.php +++ b/app/Http/Controllers/Controller.php @@ -2,10 +2,10 @@ namespace App\Http\Controllers; +use Illuminate\Foundation\Auth\Access\AuthorizesRequests; use Illuminate\Foundation\Bus\DispatchesJobs; -use Illuminate\Routing\Controller as BaseController; use Illuminate\Foundation\Validation\ValidatesRequests; -use Illuminate\Foundation\Auth\Access\AuthorizesRequests; +use Illuminate\Routing\Controller as BaseController; class Controller extends BaseController { diff --git a/app/Http/Controllers/frontEndController.php b/app/Http/Controllers/FrontEndController.php similarity index 57% rename from app/Http/Controllers/frontEndController.php rename to app/Http/Controllers/FrontEndController.php index b290f168..90237d57 100644 --- a/app/Http/Controllers/frontEndController.php +++ b/app/Http/Controllers/FrontEndController.php @@ -5,41 +5,49 @@ use App\AgendaItem; use App\MenuItem; use App\NewsItem; +use App\Repositories\AgendaItemCategoryRepository; use App\Repositories\AgendaItemRepository; -use App\Repositories\RepositorieFactory; +use App\Repositories\BookRepository; +use App\Repositories\MenuRepository; +use App\Repositories\NewsItemRepository; +use App\Repositories\UserRepository; use App\Services\AgendaApplicationFormService; -use App\Setting; use Illuminate\Http\Request; use Illuminate\Support\Facades\Redirect; -class frontEndController extends Controller +class FrontEndController extends Controller { - private $_MenuItemRepository; + private $_menuItemRepository; private $_agendaCategoryRepository; private $_newsItemRepository; private $_agendaRepository; private $_userRepository; private $_bookRepository; - public function __construct(RepositorieFactory $repositorieFactory) - { - $this->_MenuItemRepository = $repositorieFactory->getRepositorie(RepositorieFactory::$MENUREPOKEY); - $this->_agendaCategoryRepository = $repositorieFactory->getRepositorie(RepositorieFactory::$AGENDAITEMRECATEGORYPOKEY); - $this->_newsItemRepository = $repositorieFactory->getRepositorie(RepositorieFactory::$NEWSITEMREPOKEY); - $this->_agendaRepository = $repositorieFactory->getRepositorie(RepositorieFactory::$AGENDAITEMREPOKEY); - $this->_userRepository = $repositorieFactory->getRepositorie(RepositorieFactory::$USERREPOKEY); - $this->_bookRepository = $repositorieFactory->getRepositorie(RepositorieFactory::$BOOKREPOKEY); + public function __construct( + MenuRepository $menuItemRepository, + AgendaItemCategoryRepository $agendaCategoryRepository, + NewsItemRepository $newsItemRepository, + AgendaItemRepository $agendaRepository, + UserRepository $userRepository, + BookRepository $bookRepository) { + $this->_menuItemRepository = $menuItemRepository; + $this->_agendaCategoryRepository = $agendaCategoryRepository; + $this->_newsItemRepository = $newsItemRepository; + $this->_agendaRepository = $agendaRepository; + $this->_userRepository = $userRepository; + $this->_bookRepository = $bookRepository; } public function agenda() { $categories = array(); - $curPageName = trans('AgendaItems.agendaItem'); - $menuItem = $this->_MenuItemRepository->findby('urlName', MenuItem::AGENDAURL); - $content = $menuItem->content->text(); + $curPageName = 'Events'; + $menuItem = $this->_menuItemRepository->findby('urlName', MenuItem::AGENDAURL); + $content = $menuItem->content; foreach ($this->_agendaCategoryRepository->all() as $category) { - $categories[$category->id] = $category->categorieName->text(); + $categories[$category->id] = $category->name; } return view('front-end.agenda', compact('categories', 'curPageName', 'content')); @@ -50,7 +58,7 @@ public function agendaDetailView( AgendaApplicationFormService $agendaApplicationFormService ) { $users = array(); - $curPageName = $agendaItem->agendaItemTitle->text(); + $curPageName = $agendaItem->title; if ($agendaItem->application_form_id != null) { foreach ($agendaApplicationFormService->getRegisteredUsers($agendaItem)['userdata'] as $user) { $users[$user->id] = [ @@ -65,9 +73,9 @@ public function agendaDetailView( public function zekeringen() { - $curPageName = trans('front-end/zekeringen.title'); - $menuItem = $this->_MenuItemRepository->findby('urlName', MenuItem::ZEKERINGURL); - $content = $menuItem->content->text(); + $curPageName = 'Zekeringen'; + $menuItem = $this->_menuItemRepository->findby('urlName', MenuItem::ZEKERINGURL); + $content = $menuItem->content; if (!$menuItem->show()) { return Redirect::to('/login'); @@ -78,28 +86,27 @@ public function zekeringen() public function publicSubscribe() { - $menuItem = $this->_MenuItemRepository->findby('urlName', MenuItem::SUBSCRIBEURL); - $content = $menuItem->content->text(); - $curPageName = trans('front-end/subscribe.title'); - $showIntroPackageForm = app(Setting::SINGELTONNAME)->getsetting(Setting::SETTING_SHOW_INTRO_OPTION); - return view("front-end.subscribe", compact('curPageName', 'content', 'showIntroPackageForm')); + $menuItem = $this->_menuItemRepository->findby('urlName', MenuItem::SUBSCRIBEURL); + $content = $menuItem->content; + $curPageName = 'Subscribe as member'; + return view("front-end.subscribe", compact('curPageName', 'content')); } public function news() { $newsItems = NewsItem::orderBy('id', 'desc')->paginate(9); - $curPageName = trans('front-end/news.title'); - $menuItem = $this->_MenuItemRepository->findby('urlName', MenuItem::NEWSURL); - $content = $menuItem->content->text(); + $curPageName = 'News'; + $menuItem = $this->_menuItemRepository->findby('urlName', MenuItem::NEWSURL); + $content = $menuItem->content; return view("front-end.news", compact('curPageName', 'content', 'newsItems')); } public function newsDetailView(Request $request, NewsItem $newsItem) { - $curPageName = $newsItem->newsItemTitle->text(); - $menuItem = $this->_MenuItemRepository->findby('urlName', MenuItem::NEWSURL); - $content = $menuItem->content->text(); + $curPageName = $newsItem->title; + $menuItem = $this->_menuItemRepository->findby('urlName', MenuItem::NEWSURL); + $content = $menuItem->content; return view("front-end.news_detail", compact('newsItem', 'curPageName')); } @@ -107,9 +114,9 @@ public function newsDetailView(Request $request, NewsItem $newsItem) public function library() { $books = $this->_bookRepository->all(array("id", "title", "year", "type", "country", "code")); - $curPageName = trans('front-end/library.title'); - $menuItem = $this->_MenuItemRepository->findby('urlName', MenuItem::LIBRARYURL); - $content = $menuItem->content->text(); + $curPageName = 'Library'; + $menuItem = $this->_menuItemRepository->findby('urlName', MenuItem::LIBRARYURL); + $content = $menuItem->content; return view("front-end.library", compact('curPageName', 'content', 'books')); } @@ -117,9 +124,9 @@ public function library() public function memberlist() { $users = $this->_userRepository->getCurrentUsers(array('firstname', 'lastname', 'email', 'preposition', 'kind_of_member', 'phonenumber')); - $curPageName = trans('front-end/memberlist.memberlist'); - $menuItem = $this->_MenuItemRepository->findby('urlName', MenuItem::MEMBERLISTURL); - $content = $menuItem->content->text(); + $curPageName = 'Members list'; + $menuItem = $this->_menuItemRepository->findby('urlName', MenuItem::MEMBERLISTURL); + $content = $menuItem->content; if (!$menuItem->show()) { return Redirect::to('/login'); @@ -132,12 +139,11 @@ public function home(AgendaItemRepository $agendaItemRepository) { $newsItems = $this->_newsItemRepository->getLastXNewsItems(3); $agendaItems = $this->_agendaRepository->getFirstXItems(4); - $curPageName = trans('front-end/home.title'); + $curPageName = 'Home'; $menuItem = MenuItem::query() - ->with('content') ->where('urlName', '=', MenuItem::HOMEURL) ->first(); - $content = $menuItem->content->text(); + $content = $menuItem->content; return view('front-end.home', compact('newsItems', 'content', 'curPageName', 'agendaItems')); } @@ -145,7 +151,7 @@ public function home(AgendaItemRepository $agendaItemRepository) //displays the page which is requested. public function showPage(Request $request, $menuItemUrl) { - $menuItem = $this->_MenuItemRepository->findby('urlName', $menuItemUrl); + $menuItem = $this->_menuItemRepository->findby('urlName', $menuItemUrl); if ($menuItem === null) { abort(404); @@ -154,8 +160,8 @@ public function showPage(Request $request, $menuItemUrl) return Redirect::to('/login'); } - $curPageName = $menuItem->text->text(); - $content = $menuItem->content->text(); + $curPageName = $menuItem->name; + $content = $menuItem->content; return view('front-end.templade', compact('content', 'curPageName')); } } diff --git a/app/Http/Controllers/ICalController.php b/app/Http/Controllers/ICalController.php index 9d0e8af6..57f542c7 100644 --- a/app/Http/Controllers/ICalController.php +++ b/app/Http/Controllers/ICalController.php @@ -3,17 +3,14 @@ namespace App\Http\Controllers; use App\AgendaItem; -use Illuminate\Http\Request; -use Illuminate\Support\Facades\App; +use DateTimeImmutable; +use DateTimeZone as PhpDateTimeZone; use Eluceo\iCal\Domain\Entity\Calendar; use Eluceo\iCal\Domain\Entity\Event; -use Eluceo\iCal\Domain\ValueObject\Date; -use Eluceo\iCal\Presentation\Factory\CalendarFactory; -use Eluceo\iCal\Domain\ValueObject\TimeSpan; -use Eluceo\iCal\Domain\ValueObject\DateTime; use Eluceo\iCal\Domain\Entity\TimeZone; -use DateTimeZone as PhpDateTimeZone; -use DateTimeImmutable; +use Eluceo\iCal\Domain\ValueObject\DateTime; +use Eluceo\iCal\Domain\ValueObject\TimeSpan; +use Eluceo\iCal\Presentation\Factory\CalendarFactory; class ICalController extends Controller { @@ -22,8 +19,8 @@ public function getAgendaItemsICalObject() $phpDateTimeZone = new PhpDateTimeZone('Europe/Amsterdam'); $timeZone = TimeZone::createFromPhpDateTimeZone( $phpDateTimeZone, - new DateTimeImmutable(date("Y",strtotime("-1 year")) . '-' . date("m") . '-' . date("d") . ' 00:00:00', $phpDateTimeZone), - new DateTimeImmutable(date("Y",strtotime("+1 year")) . '-' . date("m") . '-' . date("d") . ' 00:00:00', $phpDateTimeZone), + new DateTimeImmutable(date("Y", strtotime("-1 year")) . '-' . date("m") . '-' . date("d") . ' 00:00:00', $phpDateTimeZone), + new DateTimeImmutable(date("Y", strtotime("+1 year")) . '-' . date("m") . '-' . date("d") . ' 00:00:00', $phpDateTimeZone), ); $agenda_items = AgendaItem::all(); @@ -34,22 +31,22 @@ public function getAgendaItemsICalObject() foreach ($agenda_items as $agenda_item) { $event = new Event(); $event - ->setOccurrence(new TimeSpan(new DateTime(new \DateTime($agenda_item->startDate), false), new DateTime(new \DateTime($agenda_item->endDate), false))) - ->setSummary($agenda_item->agendaItemTitle->text()) - ->setDescription( - html_entity_decode(strip_tags($agenda_item->agendaItemText->text())) . - "\r\n\r\n----------\r\n" . - "Meer informatie: " . url('/agenda/' . $agenda_item->id)); - $calendar->addEvent($event); + ->setOccurrence(new TimeSpan(new DateTime(new \DateTime($agenda_item->startDate), false), new DateTime(new \DateTime($agenda_item->endDate), false))) + ->setSummary($agenda_item->title) + ->setDescription( + html_entity_decode(strip_tags($agenda_item->text)) . + "\r\n\r\n----------\r\n" . + "Meer informatie: " . url('/agenda/' . $agenda_item->id)); + $calendar->addEvent($event); } $componentFactory = new CalendarFactory(); $calendarComponent = $componentFactory->createCalendar($calendar); - + // set Http headers header('Content-Type: text/calendar; charset=utf-8'); header('Content-Disposition: attachment; filename="cal.ics"'); - + echo $calendarComponent; } } diff --git a/app/Http/Controllers/LibraryController.php b/app/Http/Controllers/LibraryController.php index 51c63c42..7034aca5 100644 --- a/app/Http/Controllers/LibraryController.php +++ b/app/Http/Controllers/LibraryController.php @@ -2,90 +2,87 @@ namespace App\Http\Controllers; -use App\Repositories\RepositorieFactory; use App\Book; +use App\Repositories\BookRepository; use Illuminate\Http\Request; use Illuminate\Support\Facades\Config; use Illuminate\Support\Facades\Session; class LibraryController extends Controller { - private $_bookRepository; - /** - * Create a new controller instance. - * - * @return void - */ - public function __construct(RepositorieFactory $repositorieFactory) + + public function __construct(BookRepository $bookRepository) { $this->middleware('auth'); - $this->middleware('authorize:'.Config::get('constants.Administrator')); - $this->_bookRepository = $repositorieFactory->getRepositorie(RepositorieFactory::$BOOKREPOKEY); + $this->middleware('authorize:' . Config::get('constants.Administrator')); + + $this->_bookRepository = $bookRepository; } - //gives the book views - public function index(){ - $books = $this->_bookRepository->all(array('title','id','type','code','year','country')); + public function index() + { + $books = $this->_bookRepository->all(['title', 'id', 'type', 'code', 'year', 'country']); return view('beheer.book.index', compact('books')); } - //show create screen - public function create(){ - $fields = ['title' => trans('book.add'), + public function create() + { + $fields = [ + 'title' => 'Add a book', 'method' => 'POST', - 'url' => '/books',]; + 'url' => route('books.store'), + ]; $book = null; - return view('beheer.book.create_edit', compact('fields','book')); + return view('beheer.book.create_edit', compact('fields', 'book')); } - //store book - public function store(Request $request){ + public function store(Request $request) + { $this->validateInput($request); - $this->_bookRepository->create($request->all()); - - Session::flash("message", trans('book.added')); - return redirect('/books'); + Session::flash("message", 'Book added'); + return redirect()->route('books.index'); } - public function show(Request $request, Book $book){ + public function show(Book $book) + { return view('beheer.book.show', compact('book')); } - //show edit screen - public function edit(Request $request, Book $book){ - $fields = ['title' => trans('book.edit'), + public function edit(Book $book) + { + $fields = [ + 'title' => 'Edit book', 'method' => 'PATCH', - 'url' => '/books/'. $book->id]; - - return view('beheer.book.create_edit', compact('fields','book')); + 'url' => route('books.update', $book->id), + ]; + return view('beheer.book.create_edit', compact('fields', 'book')); } - //update book - public function update(Request $request, Book $book){ + public function update(Request $request, Book $book) + { $this->validateInput($request); - - $this->_bookRepository->update($book->id,$request->all()); - - Session::flash("message", trans('book.edited')); - return redirect('/books'); + $this->_bookRepository->update($book->id, $request->all()); + Session::flash("message", 'Book edited'); + return redirect()->route('books.index'); } - public function destroy(Request $request, Book $book){ + public function destroy(Book $book) + { $this->_bookRepository->delete($book->id); - - Session::flash("message", trans('book.deleted')); - return redirect('/books'); + Session::flash("message", 'Book removed'); + return redirect()->route('books.index'); } - private function validateInput(Request $request){ - $this->validate($request,[ - 'title' => 'required', + private function validateInput(Request $request) + { + $this->validate($request, [ + 'title' => 'required|max:255', 'year' => 'integer', - 'type' => 'required', - 'country' => 'required', - 'code' => 'required', + 'type' => 'required|max:255', + 'country' => 'required|max:255', + 'code' => 'required|max:255', ]); } } diff --git a/app/Http/Controllers/MailListController.php b/app/Http/Controllers/MailListController.php index 7817f388..c62ae455 100644 --- a/app/Http/Controllers/MailListController.php +++ b/app/Http/Controllers/MailListController.php @@ -3,7 +3,6 @@ namespace App\Http\Controllers; use App\CustomClasses\MailList\MailListFacade; -use App\MailList; use App\User; use Illuminate\Http\Request; use Illuminate\Support\Facades\Config; @@ -21,48 +20,54 @@ class MailListController extends Controller */ public function __construct(MailListFacade $mailListFacade) { - $this->_mailListFacade = $mailListFacade; + $this->_mailListFacade = $mailListFacade; $this->middleware('auth'); - $this->middleware('authorize:'.Config::get('constants.Administrator')); + $this->middleware('authorize:' . Config::get('constants.Administrator')); } //gives the mail list views - public function index(){ + public function index() + { $mailLists = $this->_mailListFacade->getAllMailLists(); return view('beheer.mailList.index', compact('mailLists')); } //show create screen - public function create(){ - $fields = ['title' => trans('MailList.add'), + public function create() + { + $fields = ['title' => 'Add mailing list', 'method' => 'POST', - 'url' => '/mailList',]; + 'url' => '/mailList']; $mailList = null; - return view('beheer.mailList.create_edit', compact('fields','mailList')); + return view('beheer.mailList.create_edit', compact('fields', 'mailList')); } //store maillist - public function store(Request $request){ + public function store(Request $request) + { $this->_mailListFacade->storeMailList($request->all()); - Session::flash("message", trans('MailList.added')); + Session::flash("message", 'Mailing list added'); return redirect('/mailList'); } - public function show(Request $request, $mailList){ + public function show(Request $request, $mailList) + { $mailList = $this->_mailListFacade->getMailList($mailList); return view('beheer.mailList.show', compact('mailList')); } - public function destroy(Request $request, $mailList){ + public function destroy(Request $request, $mailList) + { $this->_mailListFacade->deleteMailList($mailList); return redirect('/mailList'); } - public function addMember(Request $request, $mailList){ + public function addMember(Request $request, $mailList) + { $users = User::find($request->get('userIds')); foreach ($users as $user) { $this->_mailListFacade->addMember($mailList, $user->email, $user->getName()); @@ -71,8 +76,9 @@ public function addMember(Request $request, $mailList){ return ""; } - public function deleteMeberOfMailList($mailList,$member){ - $this->_mailListFacade->deleteMemberFromMailList($mailList,$member); + public function deleteMeberOfMailList($mailList, $member) + { + $this->_mailListFacade->deleteMemberFromMailList($mailList, $member); return; } diff --git a/app/Http/Controllers/ManageController.php b/app/Http/Controllers/ManageController.php index de13eb0a..cdcccd9a 100644 --- a/app/Http/Controllers/ManageController.php +++ b/app/Http/Controllers/ManageController.php @@ -2,21 +2,20 @@ namespace App\Http\Controllers; -use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; -use App\CustomClasses\MenuSingleton; class ManageController extends Controller { - - public function __construct(){ + public function __construct() + { $this->middleware('auth'); } - public function index(){ - if(Auth::guest() || !Auth::user()->hasBackendRigths()){ - abort(403, trans('validation.Unauthorized')); + public function index() + { + if (Auth::guest() || !Auth::user()->hasBackendRigths()) { + abort(403, 'You do not have sufficient access to view this page'); } return view('beheer/home'); diff --git a/app/Http/Controllers/NewsItemController.php b/app/Http/Controllers/NewsItemController.php index 89a7381d..2aca0149 100644 --- a/app/Http/Controllers/NewsItemController.php +++ b/app/Http/Controllers/NewsItemController.php @@ -3,126 +3,111 @@ namespace App\Http\Controllers; use App\NewsItem; -use App\Repositories\RepositorieFactory; +use App\Repositories\NewsItemRepository; use Illuminate\Http\Request; use Illuminate\Support\Facades\Config; +use Illuminate\Support\Facades\Session; +use Illuminate\Support\Facades\Storage; use Intervention\Image\ImageManagerStatic as Image; - class NewsItemController extends Controller { private $_newsItemRepository; - /** - * Create a new controller instance. - * - * @return void - */ - public function __construct(RepositorieFactory $repositorieFactory) + + public function __construct(NewsItemRepository $newsItemRepository) { $this->middleware('auth'); - $this->middleware('authorize:'.Config::get('constants.Content_administrator') .',' . Config::get('constants.Activity_administrator')); - $this->_newsItemRepository = $repositorieFactory->getRepositorie(RepositorieFactory::$NEWSITEMREPOKEY); + $this->middleware('authorize:' . Config::get('constants.Content_administrator') . ',' . Config::get('constants.Activity_administrator')); + + $this->_newsItemRepository = $newsItemRepository; } - //gives the news item views - public function index(){ - $newsItems = $this->_newsItemRepository->all(array("id","title","created_at","author")); + public function index() + { + $newsItems = $this->_newsItemRepository->all(['id', 'title', 'created_at', 'author']); return view('beheer.newsItem.index', compact('newsItems')); } - //show create screen - public function create(){ - $fields = ['title' => trans('NewsItem.add'), - 'method' => 'POST', - 'url' => '/newsItems',]; + public function create() + { + $fields = ['title' => 'Add a news item ', 'method' => 'POST', 'url' => '/newsItems']; $newsItem = null; - return view('beheer.newsItem.create_edit', compact('fields','newsItem')); + return view('beheer.newsItem.create_edit', compact('fields', 'newsItem')); } - //store news item - public function store(Request $request){ + public function store(Request $request) + { $this->validateInput($request); $newsItem = $this->_newsItemRepository->create($request->all()); - //save image - if($request->hasFile('thumbnail')){ - //larger header image for detail view - $name_header = $newsItem->id . '-header.' . $request->thumbnail->extension(); - $request->file('thumbnail')->storeAs('newsItems', $name_header,'public'); - $newsItem->image_url = 'newsItems/' . $name_header; - - //smaller thumbnail image for list view - $name_thumbnail = $newsItem->id . '-header.' . $request->thumbnail->extension(); - $request->file('thumbnail')->storeAs('newsItems', $name_thumbnail,'public'); - $newsItem->thumbnail_url = 'newsItems/' . $name_header; - $newsItem->save(); - - //resize both images - $header_path = storage_path('app/public/' . $newsItem->image_url); - Image::make($header_path)->fit(1200, 500)->save($header_path); - $thumb_path = storage_path('app/public/' . $newsItem->thumbnail_url); - Image::make($thumb_path)->fit(400, 300)->save($thumb_path); + if ($request->hasFile('thumbnail')) { + $this->uploadAndResizeImage($request, $newsItem); } - \Session::flash("message", trans('NewsItem.added')); + Session::flash("message", 'News item added'); return redirect('/newsItems'); } - public function show(Request $request, NewsItem $newsItem){ + public function show(Request $request, NewsItem $newsItem) + { return view('beheer.newsItem.show', compact('newsItem')); } - //show edit screen - public function edit(Request $request,NewsItem $newsItem){ - $fields = ['title' => trans('NewsItem.edit'), - 'method' => 'PATCH', - 'url' => '/newsItems/'. $newsItem->id]; - - return view('beheer.newsItem.create_edit', compact('fields','newsItem')); + public function edit(Request $request, NewsItem $newsItem) + { + $fields = ['title' => 'Edit news item ', 'method' => 'PATCH', 'url' => '/newsItems/' . $newsItem->id]; + return view('beheer.newsItem.create_edit', compact('fields', 'newsItem')); } - //update news item - public function update(Request $request,NewsItem $newsItem){ + public function update(Request $request, NewsItem $newsItem) + { $this->validateInput($request); - $this->_newsItemRepository->update($newsItem->id,$request->all()); - - //save image - if($request->hasFile('thumbnail')){ - //larger header image for detail view - $name_header = $newsItem->id . '-header.' . $request->thumbnail->extension(); - $request->file('thumbnail')->storeAs('newsItems', $name_header,'public'); - $newsItem->image_url = 'newsItems/' . $name_header; - - //smaller thumbnail image for list view - $name_thumbnail = $newsItem->id . '-thumbnail.' . $request->thumbnail->extension(); - $request->file('thumbnail')->storeAs('newsItems', $name_thumbnail,'public'); - $newsItem->thumbnail_url = 'newsItems/' . $name_thumbnail; - $newsItem->save(); - - //resize both images - $header_path = storage_path('app/public/' . $newsItem->image_url); - Image::make($header_path)->fit(1200, 500)->save($header_path); - $thumb_path = storage_path('app/public/' . $newsItem->thumbnail_url); - Image::make($thumb_path)->fit(400, 300)->save($thumb_path); + $this->_newsItemRepository->update($newsItem->id, $request->all()); + + if ($request->hasFile('thumbnail')) { + $this->uploadAndResizeImage($request, $newsItem); } - \Session::flash("message", trans('NewsItem.edited')); + Session::flash("message", 'News item edited'); return redirect('/newsItems'); } - public function destroy(Request $request, NewsItem $newsItem){ + public function destroy(Request $request, NewsItem $newsItem) + { $this->_newsItemRepository->delete($newsItem->id); - \Session::flash("message", trans('NewsItem.deleted')); + Session::flash("message", 'News item removed'); return redirect('/newsItems'); } - private function validateInput(Request $request){ - $this->validate($request,[ - 'NL_title' => 'required', - 'EN_title' => 'required', - 'NL_text' => 'required', - 'EN_text' => 'required', + private function uploadAndResizeImage($request, $newsItem) + { + $headerFileName = $newsItem->id . '-header.' . $request->thumbnail->extension(); + $thumbnailFileName = $newsItem->id . '-thumbnail.' . $request->thumbnail->extension(); + + $request->file('thumbnail')->storeAs('newsItems', $headerFileName, 'public'); + $newsItem->image_url = 'newsItems/' . $headerFileName; + + $request->file('thumbnail')->storeAs('newsItems', $thumbnailFileName, 'public'); + $newsItem->thumbnail_url = 'newsItems/' . $thumbnailFileName; + $newsItem->save(); + + //resize both images + $this->resizeImage($newsItem->image_url, 1200, 500); + $this->resizeImage($newsItem->thumbnail_url, 400, 300); + } + + private function resizeImage(string $path, int $width, int $height) + { + $imagePath = Storage::path('public/' . $path); + Image::make($imagePath)->fit($width, $height)->save($imagePath); + } + + private function validateInput(Request $request) + { + $this->validate($request, [ + 'title' => 'required|max:255', + 'text' => 'required', ]); } } diff --git a/app/Http/Controllers/PaginaBeheerController.php b/app/Http/Controllers/PaginaBeheerController.php index 3ddb8bf5..b8f345eb 100644 --- a/app/Http/Controllers/PaginaBeheerController.php +++ b/app/Http/Controllers/PaginaBeheerController.php @@ -3,7 +3,7 @@ namespace App\Http\Controllers; use App\MenuItem; -use App\Repositories\RepositorieFactory; +use App\Repositories\MenuRepository; use Illuminate\Http\Request; use Illuminate\Support\Facades\Session; @@ -16,85 +16,91 @@ class PaginaBeheerController extends Controller * * @return void */ - public function __construct(RepositorieFactory $repositorieFactory) + public function __construct(MenuRepository $menuRepository) { $this->middleware('auth'); - $this->middleware('authorize:'.\Illuminate\Support\Facades\Config::get('constants.Content_administrator')); + $this->middleware('authorize:' . \Illuminate\Support\Facades\Config::get('constants.Content_administrator')); - $this->_menuRepository = $repositorieFactory->getRepositorie(RepositorieFactory::$MENUREPOKEY); + $this->_menuRepository = $menuRepository; } //gives the rol views - public function index(){ - $pages = $this->_menuRepository->all(array("name","id","after","parent_id")); + public function index() + { + $pages = $this->_menuRepository->all(array("name", "id", "after", "parent_id")); return view('beheer.menu.index', compact('pages')); } //show create screen - public function create(){ + public function create() + { $fields = [ - 'title_menu' => trans('menuItems.addMenu'), - 'title_page' => trans('menuItems.addPage'), + 'title_menu' => 'Add menu item ', + 'title_page' => 'Add page', 'method' => 'POST', - 'url' => '/pages',]; + 'url' => '/pages']; $page = null; $pages = $this->_menuRepository->all(); - return view('beheer.menu.create_edit', compact(['page', 'fields','pages'])); + return view('beheer.menu.create_edit', compact(['page', 'fields', 'pages'])); } //store rol - public function store(Request $request){ + public function store(Request $request) + { $this->validateData($request); $this->_menuRepository->create($request->all()); - Session::flash("message", trans('menuItems.added')); + Session::flash("message", 'Page is added'); return redirect('/pages'); } - public function show(Request $request, MenuItem $page){ - $subItems = $this->_menuRepository->findBy('parent_id',$page->id); - return view('beheer.menu.show', compact('page','subItems')); + public function show(Request $request, MenuItem $page) + { + $subItems = $page->getSubMenuItems($page->id); + return view('beheer.menu.show', compact('page', 'subItems')); } //show edit screen - public function edit(Request $request,MenuItem $page){ + public function edit(Request $request, MenuItem $page) + { $fields = [ - 'title_menu' => trans('menuItems.editMenu'), - 'title_page' => trans('menuItems.editPage'), + 'title_menu' => 'Edit menu page', + 'title_page' => 'Edit page', 'method' => 'PATCH', - 'url' => '/pages/' . $page->id,]; + 'url' => '/pages/' . $page->id]; $pages = $this->_menuRepository->all(); - return view('beheer.menu.create_edit', compact(['page', 'fields','pages'])); + return view('beheer.menu.create_edit', compact(['page', 'fields', 'pages'])); } //update page - public function update(Request $request,MenuItem $page){ - if($page->urlName != $request->urlName && $page->editable){ + public function update(Request $request, MenuItem $page) + { + if ($page->urlName != $request->urlName && $page->editable) { $this->validateData($request); } - $this->_menuRepository->update($page->id,$request->all()); + $this->_menuRepository->update($page->id, $request->all()); - Session::flash("message", trans('menuItems.edited')); + Session::flash("message", 'Page is edited'); return redirect('/pages'); } - public function destroy(Request $request, MenuItem $page){ + public function destroy(Request $request, MenuItem $page) + { $this->_menuRepository->delete($page->id); - Session::flash("message", trans('menuItems.deleted')); + Session::flash("message", 'Menu item removed'); return redirect('/pages'); } - private function validateData(Request $request){ - $this->validate($request,[ + private function validateData(Request $request) + { + $this->validate($request, [ 'urlName' => 'required|max:255|unique:menu_items', 'itemType' => 'required', - 'NL_text' => 'required', - 'EN_text' => 'required', - 'content_nl' => 'required', - 'content_en' => 'required', + 'name' => 'required|max:255', + 'content' => 'required', 'afterItem' => 'required', ]); diff --git a/app/Http/Controllers/PendingUserController.php b/app/Http/Controllers/PendingUserController.php index ad57d75b..02886a38 100644 --- a/app/Http/Controllers/PendingUserController.php +++ b/app/Http/Controllers/PendingUserController.php @@ -2,7 +2,7 @@ namespace App\Http\Controllers; -use App\Repositories\RepositorieFactory as RepositorieFactory; +use App\Repositories\UserRepository; use App\Rules\EmailDomainValidator; use App\User; use Illuminate\Http\Request; @@ -18,11 +18,12 @@ class PendingUserController extends Controller * * @return void */ - public function __construct(RepositorieFactory $repositoryFactory) + public function __construct(UserRepository $userRepository) { $this->middleware('auth')->except('storePendingUser'); $this->middleware('authorize:' . Config::get('constants.Administrator'))->except('storePendingUser'); - $this->_userRepository = $repositoryFactory->getRepositorie(RepositorieFactory::$USERREPOKEY); + + $this->_userRepository = $userRepository; } //pending users view @@ -40,9 +41,9 @@ public function storePendingUser(Request $request) $user = $this->_userRepository->createPendingUser($request->all()); - Session::flash("message", trans('front-end/subscribe.success')); + Session::flash("message", 'Your membership request is pending, we will get back to you as soon as possible'); - return redirect('/lidworden'); + return redirect('/signup'); } public function removeAsPendingMember(Request $request, User $user) @@ -69,22 +70,22 @@ private function validateInput(Request $request) 'unique:users', new EmailDomainValidator(), ], - 'firstname' => 'required', - 'lastname' => 'required', - 'street' => 'required', - 'houseNumber' => 'required', - 'city' => 'required', - 'zipcode' => 'required', - 'country' => 'required', - 'phonenumber' => 'required', - 'emergencyNumber' => 'required', - 'emergencyHouseNumber' => 'required', - 'emergencystreet' => 'required', - 'emergencycity' => 'required', - 'emergencyzipcode' => 'required', - 'emergencycountry' => 'required', + 'firstname' => 'required|max:255', + 'lastname' => 'required|max:255', + 'street' => 'required|max:255', + 'houseNumber' => 'required|max:255', + 'city' => 'required|max:255', + 'zipcode' => 'required|max:255', + 'country' => 'required|max:255', + 'phonenumber' => 'required|max:255', + 'emergencyNumber' => 'required|max:255', + 'emergencyHouseNumber' => 'required|max:255', + 'emergencystreet' => 'required|max:255', + 'emergencycity' => 'required|max:255', + 'emergencyzipcode' => 'required|max:255', + 'emergencycountry' => 'required|max:255', 'birthDay' => 'required|date', - 'IBAN' => 'required', + 'IBAN' => 'required|max:255', 'g-recaptcha-response' => 'required', 'incasso' => 'required', 'privacy_policy' => 'required', diff --git a/app/Http/Controllers/RolController.php b/app/Http/Controllers/RolController.php index 7ea6695d..e8e3fb01 100644 --- a/app/Http/Controllers/RolController.php +++ b/app/Http/Controllers/RolController.php @@ -2,7 +2,7 @@ namespace App\Http\Controllers; -use App\Repositories\RepositorieFactory; +use App\Repositories\RolRepository; use App\Rol; use Illuminate\Http\Request; use Illuminate\Support\Facades\Config; @@ -17,72 +17,80 @@ class RolController extends Controller * * @return void */ - public function __construct(RepositorieFactory $repositorieFactory) + public function __construct(RolRepository $rolRepository) { $this->middleware('auth'); - $this->middleware('authorize:'.Config::get('constants.Administrator')); - $this->_rolRepository = $repositorieFactory->getRepositorie(RepositorieFactory::$ROLREPOKEY); + $this->middleware('authorize:' . Config::get('constants.Administrator')); + + $this->_rolRepository = $rolRepository; } //gives the rol views - public function index(){ - $rols = $this->_rolRepository->all(array('name','id')); + public function index() + { + $rols = $this->_rolRepository->all(array('name', 'id')); return view('beheer.rol.index', compact('rols')); } //show create screen - public function create(){ - $fields = ['title' => trans('rol.add'), + public function create() + { + $fields = ['title' => 'Add a role', 'method' => 'POST', - 'url' => '/rols',]; + 'url' => '/rols']; $rol = null; - return view('beheer.rol.create_edit', compact('fields','rol')); + return view('beheer.rol.create_edit', compact('fields', 'rol')); } //store rol - public function store(Request $request){ + public function store(Request $request) + { $this->validateInput($request); $this->_rolRepository->create($request->all()); - Session::flash("message", trans('rol.added')); + Session::flash("message", 'Role added'); return redirect('/rols'); } - public function show(Request $request, Rol $rol){ + public function show(Request $request, Rol $rol) + { return view('beheer.rol.show', compact('rol')); } //show edit screen - public function edit(Request $request,Rol $rol){ - $fields = ['title' => trans('rol.edit'), + public function edit(Request $request, Rol $rol) + { + $fields = ['title' => 'Edit role', 'method' => 'PATCH', - 'url' => '/rols/'. $rol->id]; + 'url' => '/rols/' . $rol->id]; - return view('beheer.rol.create_edit', compact('fields','rol')); + return view('beheer.rol.create_edit', compact('fields', 'rol')); } //update rol - public function update(Request $request,Rol $rol){ + public function update(Request $request, Rol $rol) + { $this->validateInput($request); - $this->_rolRepository->update($rol->id,$request->all()); + $this->_rolRepository->update($rol->id, $request->all()); - Session::flash("message", trans('rol.edited')); + Session::flash("message", 'Role edited'); return redirect('/rols'); } - public function destroy(Request $request, Rol $rol){ + public function destroy(Request $request, Rol $rol) + { $this->_rolRepository->delete($rol->id); - Session::flash("message", trans('rol.deleted')); + Session::flash("message", 'Role removed'); return redirect('/rols'); } - private function validateInput(Request $request){ - $this->validate($request,[ - 'EN_text' => 'required', - 'NL_text' => 'required', + private function validateInput(Request $request) + { + $this->validate($request, [ + 'name' => 'required|max:255', ]); } } diff --git a/app/Http/Controllers/SettingsController.php b/app/Http/Controllers/SettingsController.php index 802c8cc0..0036bebc 100644 --- a/app/Http/Controllers/SettingsController.php +++ b/app/Http/Controllers/SettingsController.php @@ -6,70 +6,37 @@ use Illuminate\Http\Request; use Illuminate\Support\Facades\Config; use Illuminate\Support\Facades\Session; -use Symfony\Component\HttpFoundation\Session\Session as SymfonySession; class SettingsController extends Controller { - private $_LANGSESSIONNAME = "lang"; - - /** - * Create a new controller instance. - * - * @return void - */ public function __construct() { - $this->middleware('auth')->except('setLanguage');; - $this->middleware('authorize:' . Config::get('constants.Administrator')) - ->except('setLanguage'); + $this->middleware('auth'); + $this->middleware('authorize:' . Config::get('constants.Administrator')); } - /** - * Display a listing of the resource. - * - * @return \Illuminate\Http\Response - */ public function index() { $settings = Setting::all(); - return view('beheer.settings.index',compact('settings')); + return view('beheer.settings.index', compact('settings')); } - /** - * Show the form for editing the specified resource. - * - * @param int $id - * @return \Illuminate\Http\Response - */ public function edit() { $settings = Setting::all(); - return view('beheer.settings.edit',compact('settings')); + return view('beheer.settings.edit', compact('settings')); } - /** - * Update the specified resource in storage. - * - * @param \Illuminate\Http\Request $request - * @param int $id - * @return \Illuminate\Http\Response - */ public function update(Request $request) { $settings = Setting::all(); - foreach ($request->get('setting',[]) as $key => $value){ - $setting = $settings->where('name','=',$key)->first(); + foreach ($request->get('setting', []) as $key => $value) { + $setting = $settings->where('name', '=', $key)->first(); $setting->value = $value; $setting->save(); } - Session::flash("message", trans('settings.flashUpdateSetting')); + Session::flash("message", 'Settings updated'); return redirect('/beheer/settings'); } - - public function setLanguage(Request $request){ - $language = $request->get('language','nl'); - $request->session()->put($this->_LANGSESSIONNAME,$language); - return ""; - } } diff --git a/app/Http/Controllers/StorageController.php b/app/Http/Controllers/StorageController.php index c56a8632..b52bda63 100644 --- a/app/Http/Controllers/StorageController.php +++ b/app/Http/Controllers/StorageController.php @@ -7,13 +7,10 @@ class StorageController extends Controller { - /** - * StorageController constructor. - */ public function __construct() { $this->middleware('auth'); - $this->middleware('authorize:'.\Illuminate\Support\Facades\Config::get('constants.Content_administrator')); + $this->middleware('authorize:' . \Illuminate\Support\Facades\Config::get('constants.Content_administrator')); } public function uploadImage(Request $request) @@ -27,4 +24,4 @@ public function deleteImage(Request $request) { Storage::disk('public')->delete($request->path); } -} \ No newline at end of file +} diff --git a/app/Http/Controllers/UserCertificateController.php b/app/Http/Controllers/UserCertificateController.php index 81459d30..35597341 100644 --- a/app/Http/Controllers/UserCertificateController.php +++ b/app/Http/Controllers/UserCertificateController.php @@ -3,7 +3,8 @@ namespace App\Http\Controllers; use App\Certificate; -use App\Repositories\RepositorieFactory; +use App\Repositories\CertificateRepository; +use App\Repositories\UserRepository; use App\User; use Illuminate\Http\Request; use Illuminate\Support\Facades\Config; @@ -17,74 +18,80 @@ class UserCertificateController extends Controller * * @return void */ - public function __construct(RepositorieFactory $repositoryFactory) + public function __construct(UserRepository $userRepository, CertificateRepository $certificateRepository) { $this->middleware('auth'); - $this->middleware('authorize:'.\Config::get('constants.Administrator') .',' . \Config::get('constants.Certificate_administrator')); - $this->_userRepository = $repositoryFactory->getRepositorie(RepositorieFactory::$USERREPOKEY); - $this->_certificateRepository = $repositoryFactory->getRepositorie(RepositorieFactory::$CERTIFICATEREPOKEY); + $this->middleware('authorize:' . Config::get('constants.Administrator') . ',' . Config::get('constants.Certificate_administrator')); + + $this->_userRepository = $userRepository; + $this->_certificateRepository = $certificateRepository; } - public function addCertificate(Request $request, User $user){ - $fields = ['title' => trans('user.addCertificate'), + public function addCertificate(Request $request, User $user) + { + $fields = ['title' => 'Add certificate', 'method' => 'POST', - 'url' => '/users/'. $user->id . '/addCertificate']; + 'url' => '/users/' . $user->id . '/addCertificate']; $certificates = array(); $userCertificates = $this->_userRepository->getUserCertificates($user->id); - foreach ( $this->_certificateRepository->all() as $cetificate){ - if(!$userCertificates->contains($cetificate)){ - $certificates[$cetificate->id] = $cetificate->certificateName->text(); + foreach ($this->_certificateRepository->all() as $cetificate) { + if (!$userCertificates->contains($cetificate)) { + $certificates[$cetificate->id] = $cetificate->name; } } $userCertificate = null; - return view('beheer.user.addCertificate', compact(["fields","certificates","userCertificate"])); + return view('beheer.user.addCertificate', compact(["fields", "certificates", "userCertificate"])); } - public function saveCertificate(Request $request, User $user){ + public function saveCertificate(Request $request, User $user) + { $this->validateInput($request); - $this->_userRepository->addCertificate($user->id,$request->all()); + $this->_userRepository->addCertificate($user->id, $request->all()); - return redirect('/users/'. $user->id); + return redirect('/users/' . $user->id); } - public function editUserCertificate(Request $request, User $user, Certificate $certificate){ - $fields = ['title' => trans('user.editCertificate'), + public function editUserCertificate(Request $request, User $user, Certificate $certificate) + { + $fields = ['title' => 'Edit certificate', 'method' => 'PATCH', - 'url' => '/users/'. $user->id . '/addCertificate/'. $certificate->id]; + 'url' => '/users/' . $user->id . '/addCertificate/' . $certificate->id]; $certificates = array(); - foreach ( $this->_certificateRepository->all() as $cetificate){ - $certificates[$cetificate->id] = $cetificate->certificateName->text(); + foreach ($this->_certificateRepository->all() as $cetificate) { + $certificates[$cetificate->id] = $cetificate->name; } $userCertificate = $user->certificates()->find($certificate->id); - return view('beheer.user.addCertificate', compact(["fields","certificates","userCertificate"])); + return view('beheer.user.addCertificate', compact(["fields", "certificates", "userCertificate"])); } - public function updateUserCertificate(Request $request, User $user, Certificate $certificate){ + public function updateUserCertificate(Request $request, User $user, Certificate $certificate) + { $this->validateInput($request); $user->certificates()->detach($certificate->id); - $this->_userRepository->addCertificate($user->id,$request->all()); - return redirect('/users/'. $user->id); + $this->_userRepository->addCertificate($user->id, $request->all()); + return redirect('/users/' . $user->id); } - public function deleteUserCertificate(Request $request, User $user, Certificate $certificate){ + public function deleteUserCertificate(Request $request, User $user, Certificate $certificate) + { $user->certificates()->detach($certificate->id); - return redirect('/users/'. $user->id); + return redirect('/users/' . $user->id); } - private function validateInput(Request $request){ - $this->validate($request,[ + private function validateInput(Request $request) + { + $this->validate($request, [ 'certificate_id' => 'required|numeric|min:0', - 'startDate' => 'required|date', ]); } } diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index bdc6a932..9b7a98d9 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -2,10 +2,9 @@ namespace App\Http\Controllers; -use App\Certificate; -use App\Exports\UsersExport; use App\CustomClasses\MailList\MailListFacade; -use App\Repositories\RepositorieFactory as RepositorieFactory; +use App\Exports\UsersExport; +use App\Repositories\UserRepository; use App\Rol; use App\Rules\EmailDomainValidator; use App\User; @@ -24,147 +23,159 @@ class UserController extends Controller * * @return void */ - public function __construct(RepositorieFactory $repositoryFactory) + public function __construct(UserRepository $userRepository) { $this->middleware('auth'); // The edit, update, and show methods check the authorization themselves, so we don't apply a role middleware there. // Only the index method is accessible by both Administrators and Certificate admins, so we apply a different middleware there. - $this->middleware('authorize:'.\Config::get('constants.Administrator'))->except(['edit', 'update', 'show', 'index']); - $this->middleware('authorize:'.\Config::get('constants.Administrator') .',' . \Config::get('constants.Certificate_administrator'))->only(['index']); - $this->_userRepository = $repositoryFactory->getRepositorie(RepositorieFactory::$USERREPOKEY); + $this->middleware('authorize:' . Config::get('constants.Administrator'))->except(['edit', 'update', 'show', 'index']); + $this->middleware('authorize:' . Config::get('constants.Administrator') . ',' . Config::get('constants.Certificate_administrator'))->only(['index']); + + $this->_userRepository = $userRepository; } //gives the user views - public function index(){ - $users = $this->_userRepository->getCurrentUsers(array('id','firstname','lastname','email','preposition','kind_of_member'), ['roles']); + public function index() + { + $users = $this->_userRepository->getCurrentUsers(array('id', 'firstname', 'lastname', 'email', 'preposition', 'kind_of_member'), ['roles']); $roles = Rol::all(); - return view('beheer.user.index', compact('users','roles')); + return view('beheer.user.index', compact('users', 'roles')); } //gives the old users view - public function indexOldMembers() { - $users = $this->_userRepository->getOldUsers(array('id','firstname','lastname','email','preposition','kind_of_member')); + public function indexOldMembers() + { + $users = $this->_userRepository->getOldUsers(array('id', 'firstname', 'lastname', 'email', 'preposition', 'kind_of_member')); return view('beheer.user.index_old_users', compact('users')); } //show create screen - public function create(){ - $fields = ['title' => trans('user.add'), + public function create() + { + $fields = ['title' => 'Add user', 'method' => 'POST', - 'url' => '/users',]; + 'url' => '/users']; $user = null; $roles = Rol::all(); $ownedRoles = collect(); - return view('beheer.user.create_edit', compact('fields','user','roles', 'ownedRoles')); + return view('beheer.user.create_edit', compact('fields', 'user', 'roles', 'ownedRoles')); } //store user - public function store(Request $request){ + public function store(Request $request) + { $this->validateInput($request); $user = $this->_userRepository->create($request->all()); - if($request->get('roles') != null){ + if ($request->get('roles') != null) { $this->_userRepository->addRols($user->id, $request->get('roles')); } - Session::flash("message", trans('user.added')); + Session::flash("message", 'User is added'); return redirect('/users'); } - public function show(Request $request, User $user){ - if(Auth::user()->id != $user->id && !Auth::user()->hasRole(Config::get('constants.Administrator'),Config::get('constants.Certificate_administrator'))){ - abort(403, trans('validation.Unauthorized')); + public function show(Request $request, User $user) + { + if (Auth::user()->id != $user->id && !Auth::user()->hasRole(Config::get('constants.Administrator'), Config::get('constants.Certificate_administrator'))) { + abort(403, 'You do not have sufficient access to view this page'); } return view('beheer.user.show', compact('user')); } //show edit screen - public function edit(Request $request,User $user){ - if(Auth::user()->id != $user->id && !Auth::user()->hasRole(Config::get('constants.Administrator'))){ - abort(403, trans('validation.Unauthorized')); + public function edit(Request $request, User $user) + { + if (Auth::user()->id != $user->id && !Auth::user()->hasRole(Config::get('constants.Administrator'))) { + abort(403, 'You do not have sufficient access to view this page'); } - $fields = ['title' => trans('user.edit'), + $fields = ['title' => 'Edit user', 'method' => 'PATCH', - 'url' => '/users/'. $user->id]; + 'url' => '/users/' . $user->id]; $roles = Rol::all(); $ownedRoles = $user->roles; - return view('beheer.user.create_edit', compact('fields','user','roles', 'ownedRoles')); + return view('beheer.user.create_edit', compact('fields', 'user', 'roles', 'ownedRoles')); } //update user - public function update(Request $request, User $user, MailListFacade $mailListFacade){ - if(!Auth::user()->hasRole(Config::get('constants.Administrator'))){ - if(Auth::user()->id != $user->id || $request->has('kind_of_member')){ - abort(403, trans('validation.Unauthorized')); + public function update(Request $request, User $user, MailListFacade $mailListFacade) + { + if (!Auth::user()->hasRole(Config::get('constants.Administrator'))) { + if (Auth::user()->id != $user->id || $request->has('kind_of_member')) { + abort(403, 'You do not have sufficient access to view this page'); } } - if($user->email != $request['email']){ + if ($user->email != $request['email']) { //check if email is unique $this->validateInput($request); - $mailListFacade->updateUserEmailFormAllMailList($user,$user->email,$request['email']); + $mailListFacade->updateUserEmailFormAllMailList($user, $user->email, $request['email']); } $this->_userRepository->update($user->id, $request->all()); - if(Auth::user()->hasRole(Config::get('constants.Administrator'))){ - $this->_userRepository->addRols($user->id, $request->get('roles',[])); + if (Auth::user()->hasRole(Config::get('constants.Administrator'))) { + $this->_userRepository->addRols($user->id, $request->get('roles', [])); } - if(Auth::user()->id === $user->id){ - return redirect('/users/'. $user->id . '?back=false'); - } else{ - Session::flash("message", trans('user.edited')); + if (Auth::user()->id === $user->id) { + return redirect('/users/' . $user->id . '?back=false'); + } else { + Session::flash("message", 'Changes to user have been saved'); return redirect('/users'); } } - public function removeAsActiveMember(Request $request, User $user, MailListFacade $mailListFacade){ + public function removeAsActiveMember(Request $request, User $user, MailListFacade $mailListFacade) + { $user->removeAsActiveMember(); $mailListFacade->deleteUserFormAllMailList($user); - return redirect('/users/'. $user->id); + return redirect('/users/' . $user->id); } - public function exportUsers(UsersExport $usersExport){ - return Excel::download($usersExport, trans('user.members') . '.xlsx'); + public function exportUsers(UsersExport $usersExport) + { + return Excel::download($usersExport, 'Members' . '.xlsx'); } - public function makeActiveMember(Request $request, User $user){ + public function makeActiveMember(Request $request, User $user) + { $user->makeActiveMember(); - return redirect('/users/'. $user->id); + return redirect('/users/' . $user->id); } - private function validateInput(Request $request){ - $this->validate($request,[ + private function validateInput(Request $request) + { + $this->validate($request, [ 'email' => [ 'required', 'email', 'max:255', 'unique:users', - new EmailDomainValidator() + new EmailDomainValidator(), ], - 'firstname' => 'required', - 'lastname' => 'required', - 'street' => 'required', - 'houseNumber' => 'required', - 'city' => 'required', - 'zipcode' => 'required', - 'country' => 'required', - 'phonenumber' => 'required', - 'emergencyNumber' => 'required', - 'emergencyHouseNumber' => 'required', - 'emergencystreet' => 'required', - 'emergencycity' => 'required', - 'emergencyzipcode' => 'required', - 'emergencycountry' => 'required', + 'firstname' => 'required|max:255', + 'lastname' => 'required|max:255', + 'street' => 'required|max:255', + 'houseNumber' => 'required|max:255', + 'city' => 'required|max:255', + 'zipcode' => 'required|max:255', + 'country' => 'required|max:255', + 'phonenumber' => 'required|max:255', + 'emergencyNumber' => 'required|max:255', + 'emergencyHouseNumber' => 'required|max:255', + 'emergencystreet' => 'required|max:255', + 'emergencycity' => 'required|max:255', + 'emergencyzipcode' => 'required|max:255', + 'emergencycountry' => 'required|max:255', 'birthDay' => 'required|date', - 'IBAN' => 'required' + 'IBAN' => 'required|max:255', ]); // These fields are only required for administrators. diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index 5d4a970c..61437769 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -31,7 +31,6 @@ class Kernel extends HttpKernel \Illuminate\View\Middleware\ShareErrorsFromSession::class, \App\Http\Middleware\VerifyCsrfToken::class, \Illuminate\Routing\Middleware\SubstituteBindings::class, - \App\Http\Middleware\Language::class, \App\Http\Middleware\CheckKillswitch::class, ], diff --git a/app/Http/Middleware/Authorize.php b/app/Http/Middleware/Authorize.php index f8b5b1b6..3198ffee 100644 --- a/app/Http/Middleware/Authorize.php +++ b/app/Http/Middleware/Authorize.php @@ -14,12 +14,12 @@ class Authorize * @param \Closure $next * @return mixed */ - public function handle($request, Closure $next, $role,$role2 = "-1") + public function handle($request, Closure $next, $role, $role2 = "-1") { - if(Auth::user()->hasRole($role,$role2)){ + if (Auth::user()->hasRole($role, $role2)) { return $next($request); } else { - abort(403, trans('validation.Unauthorized')); + abort(403, 'You do not have sufficient access to view this page'); } } diff --git a/app/Http/Middleware/CheckKillswitch.php b/app/Http/Middleware/CheckKillswitch.php index 3d8e283b..45a7f1bd 100644 --- a/app/Http/Middleware/CheckKillswitch.php +++ b/app/Http/Middleware/CheckKillswitch.php @@ -2,10 +2,8 @@ namespace App\Http\Middleware; -use Closure; use App\Setting; -use App\MenuItem; -use App\CustomClasses\MenuSingleton; +use Closure; class CheckKillswitch { @@ -24,10 +22,10 @@ class CheckKillswitch public function handle($request, Closure $next) { - if(app(Setting::SINGELTONNAME)->getsetting(Setting::SETTING_KILLSWITCH) && ! $request->is($this->excludedRoutes)) { - $curPageName = trans('front-end/killswitch.title'); + if (app(Setting::SINGELTONNAME)->getsetting(Setting::SETTING_KILLSWITCH) && !$request->is($this->excludedRoutes)) { + $curPageName = 'Website offline'; - return response()->view('errors.killswitch',compact('curPageName'), 404); + return response()->view('errors.killswitch', compact('curPageName'), 404); } return $next($request); diff --git a/app/Http/Middleware/Language.php b/app/Http/Middleware/Language.php deleted file mode 100644 index e7b2821a..00000000 --- a/app/Http/Middleware/Language.php +++ /dev/null @@ -1,31 +0,0 @@ - "nl", - "en" => "en", - ]; - /** - * Handle an incoming request. - * - * @param \Illuminate\Http\Request $request - * @param \Closure $next - * @return mixed - */ - public function handle($request, Closure $next) - { - $language = $request->session()->get($this->_LANGSESSIONNAME,'nl'); - if(array_key_exists($language,$this->_LANGLOOKUP)){ - \App::setLocale($this->_LANGLOOKUP[$language]); - } - - return $next($request); - } -} diff --git a/app/Http/Requests/ApplicationFormStoreRequest.php b/app/Http/Requests/ApplicationFormStoreRequest.php index 718cb7a2..a0fb45d9 100644 --- a/app/Http/Requests/ApplicationFormStoreRequest.php +++ b/app/Http/Requests/ApplicationFormStoreRequest.php @@ -14,10 +14,8 @@ class ApplicationFormStoreRequest extends FormRequest public function rules() { return [ - 'nl_name' => 'required', - 'en_name' => 'required', - 'rows.*.nl_name' => 'required', - 'rows.*.en_name' => 'required', + 'name' => 'required', + 'rows.*.name' => 'required', 'rows.*.type' => 'required', ]; } diff --git a/app/Http/Resources/ApplicationFormRowOptionVueResource.php b/app/Http/Resources/ApplicationFormRowOptionVueResource.php index dd871edd..3c532d5d 100644 --- a/app/Http/Resources/ApplicationFormRowOptionVueResource.php +++ b/app/Http/Resources/ApplicationFormRowOptionVueResource.php @@ -15,10 +15,9 @@ class ApplicationFormRowOptionVueResource extends JsonResource public function toArray($request) { return [ - 'id' => $this->id, - 'nameNL' => $this->applicationFormRowOptionName->NL_text, - 'nameEN' => $this->applicationFormRowOptionName->EN_text, - 'value' => $this->value, + 'id' => $this->id, + 'name' => $this->name, + 'value' => $this->value, ]; } } diff --git a/app/Http/Resources/ApplicationFormRowVueResource.php b/app/Http/Resources/ApplicationFormRowVueResource.php index 5775c21a..4e31fa45 100644 --- a/app/Http/Resources/ApplicationFormRowVueResource.php +++ b/app/Http/Resources/ApplicationFormRowVueResource.php @@ -23,11 +23,10 @@ class ApplicationFormRowVueResource extends JsonResource public function toArray($request) { return [ - 'nameNL' => $this->applicationFormRowName->NL_text, - 'nameEN' => $this->applicationFormRowName->EN_text, - 'type' => $this->type, - 'required' => $this->required, - 'id' => $this->id, + 'name' => $this->name, + 'type' => $this->type, + 'required' => $this->required, + 'id' => $this->id, 'applicationFormRowOptions' => ApplicationFormRowOptionVueResource::collection($this->applicationFormRowOptions), ]; } diff --git a/app/MenuItem.php b/app/MenuItem.php index 277b6dca..9f73bcc7 100644 --- a/app/MenuItem.php +++ b/app/MenuItem.php @@ -4,7 +4,6 @@ use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\SoftDeletes; -use Illuminate\Support\Facades\App; use Illuminate\Support\Facades\Auth; class MenuItem extends Model @@ -13,11 +12,11 @@ class MenuItem extends Model const HOMEURL = 'home'; const ZEKERINGURL = 'zekeringen'; - const SUBSCRIBEURL = 'lidworden'; - const NEWSURL = 'nieuws'; - const MEMBERLISTURL = 'ledenlijst'; + const SUBSCRIBEURL = 'signup'; + const NEWSURL = 'news'; + const MEMBERLISTURL = 'memberlist'; const AGENDAURL = 'agenda'; - const LIBRARYURL = 'bibliotheek'; + const LIBRARYURL = 'library'; protected $fillable = [ 'name', @@ -27,19 +26,9 @@ class MenuItem extends Model 'menuItem', 'deletable', 'editable', - 'content_id', + 'content', ]; - public function text() - { - return $this->hasOne('App\Text', 'id', 'name'); - } - - public function content() - { - return $this->hasOne(Text::class, 'id', 'content_id'); - } - public function partner() { return $this->hasOne('App\MenuItem', 'id', 'parent_id'); @@ -61,11 +50,6 @@ public function getSubMenuItems($id) return MenuItem::query()->where('parent_id', '=', $id)->where('menuItem', '=', true)->get(); } - public function getPageName() - { - return 'pages.' . $this->urlName . ((App::isLocale('en') === true) ? '_en' : '_nl'); - } - public function show() { if ($this->login) { diff --git a/app/Models/ApplicationForm/ApplicationForm.php b/app/Models/ApplicationForm/ApplicationForm.php index 28374353..5164bd8d 100644 --- a/app/Models/ApplicationForm/ApplicationForm.php +++ b/app/Models/ApplicationForm/ApplicationForm.php @@ -2,10 +2,8 @@ namespace App\Models\ApplicationForm; -use App\Text; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\HasMany; -use Illuminate\Database\Eloquent\Relations\HasOne; use Illuminate\Database\Eloquent\SoftDeletes; /** @@ -20,20 +18,14 @@ class ApplicationForm extends Model * @var array */ protected $fillable = [ - 'name' + 'name', ]; - /** - * @return HasOne - */ - public function applicationFormName(): HasOne{ - return $this->hasOne(Text::class, 'id', 'name')->withTrashed(); - } - /** * @return HasMany */ - public function applicationFormRows(): HasMany{ - return $this->hasMany(ApplicationFormRow::class,'application_form_id'); + public function applicationFormRows(): HasMany + { + return $this->hasMany(ApplicationFormRow::class, 'application_form_id'); } } diff --git a/app/Models/ApplicationForm/ApplicationFormRow.php b/app/Models/ApplicationForm/ApplicationFormRow.php index 153d1f1e..eefe7fe3 100644 --- a/app/Models/ApplicationForm/ApplicationFormRow.php +++ b/app/Models/ApplicationForm/ApplicationFormRow.php @@ -2,10 +2,8 @@ namespace App\Models\ApplicationForm; -use App\Text; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\HasMany; -use Illuminate\Database\Eloquent\Relations\HasOne; use Illuminate\Database\Eloquent\SoftDeletes; /** @@ -19,17 +17,17 @@ class ApplicationFormRow extends Model /** * @var string */ - const FORM_TYPE_SELECT = 'select'; + const FORM_TYPE_SELECT = 'select'; /** * @var string */ - const FORM_TYPE_RADIO = 'radio'; + const FORM_TYPE_RADIO = 'radio'; /** * @var string */ - const FORM_TYPE_TEXT_BOX = 'textBox'; + const FORM_TYPE_TEXT_BOX = 'textBox'; /** * @var string @@ -39,17 +37,17 @@ class ApplicationFormRow extends Model /** * @var string */ - const FORM_TYPE_NUMBER = 'number'; + const FORM_TYPE_NUMBER = 'number'; /** * @var string */ - const FORM_TYPE_TEXT = 'text'; + const FORM_TYPE_TEXT = 'text'; /** * @var array */ - protected $fillable = [ + protected $fillable = [ 'name', 'application_form_id', 'type', @@ -60,7 +58,7 @@ class ApplicationFormRow extends Model * @var array */ protected $casts = [ - 'required' => 'boolean' + 'required' => 'boolean', ]; /** @@ -68,14 +66,6 @@ class ApplicationFormRow extends Model */ private $_inputfiels = null; - /** - * @return HasOne - */ - public function applicationFormRowName(): HasOne - { - return $this->hasOne(Text::class, 'id', 'name')->withTrashed(); - } - /** * @return HasMany */ diff --git a/app/Models/ApplicationForm/ApplicationFormRowOption.php b/app/Models/ApplicationForm/ApplicationFormRowOption.php index 003e2814..6ee9e406 100644 --- a/app/Models/ApplicationForm/ApplicationFormRowOption.php +++ b/app/Models/ApplicationForm/ApplicationFormRowOption.php @@ -2,9 +2,7 @@ namespace App\Models\ApplicationForm; -use App\Text; use Illuminate\Database\Eloquent\Model; -use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\SoftDeletes; /** @@ -19,12 +17,7 @@ class ApplicationFormRowOption extends Model * @var array */ protected $fillable = [ - 'name_id', - 'value' + 'name', + 'value', ]; - - public function applicationFormRowOptionName(): BelongsTo - { - return $this->belongsTo(Text::class, 'name_id'); - } } diff --git a/app/Models/ApplicationForm/ApplicationResponse.php b/app/Models/ApplicationForm/ApplicationResponse.php index 65da793d..e7e8082b 100644 --- a/app/Models/ApplicationForm/ApplicationResponse.php +++ b/app/Models/ApplicationForm/ApplicationResponse.php @@ -1,7 +1,6 @@ belongsTo(User::class); } -} \ No newline at end of file +} diff --git a/app/Models/ApplicationForm/ApplicationResponseRow.php b/app/Models/ApplicationForm/ApplicationResponseRow.php index aef0008e..44d5ca02 100644 --- a/app/Models/ApplicationForm/ApplicationResponseRow.php +++ b/app/Models/ApplicationForm/ApplicationResponseRow.php @@ -2,8 +2,6 @@ namespace App\Models\ApplicationForm; -; - use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\HasOne; use Illuminate\Database\Eloquent\SoftDeletes; @@ -23,7 +21,7 @@ class ApplicationResponseRow extends Model 'id', 'application_response_id', 'application_form_row_id', - 'value' + 'value', ]; /** @@ -38,9 +36,9 @@ public function getFormattedValueAttribute(): string { switch ($this->getApplicationFormRow->type) { case ApplicationFormRow::FORM_TYPE_CHECK_BOX: - return $this->value === 'on' ? trans('inschrijven.yes') : trans('inschrijven.no'); + return $this->value === 'on' ? 'Yes' : 'No'; default: return $this->value; } } -} \ No newline at end of file +} diff --git a/app/NewsItem.php b/app/NewsItem.php index 6f3863e1..596c7118 100644 --- a/app/NewsItem.php +++ b/app/NewsItem.php @@ -4,6 +4,7 @@ use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\SoftDeletes; +use Illuminate\Support\Facades\Storage; class NewsItem extends Model { @@ -13,32 +14,20 @@ class NewsItem extends Model 'text', 'image_url', 'thumbnail_url', - 'author' + 'author', ]; - public function newsItemText(){ - return $this->hasOne('App\Text', 'id', 'text'); - } - - public function newsItemTitle() + public function getImageUrl() { - return $this->hasOne('App\Text', 'id', 'title'); - } - - public function getImageUrl(){ - if($this->image_url != ""){ - return \Storage::disk('public')->url($this->image_url); - } else { - return "/img/header-3.jpg"; - } + return $this->image_url != "" + ? Storage::disk('public')->url($this->image_url) + : "/img/header-3.jpg"; } - public function getThumbnailUrl(){ - if($this->thumbnail_url != ""){ - return \Storage::disk('public')->url($this->thumbnail_url); - } else { - return "/img/header-3.jpg"; - } - + public function getThumbnailUrl() + { + return $this->thumbnail_url != "" + ? Storage::disk('public')->url($this->thumbnail_url) + : "/img/header-3.jpg"; } } diff --git a/app/Observers/ApplicationResponseObserver.php b/app/Observers/ApplicationResponseObserver.php index 7995a866..4a4bc55f 100644 --- a/app/Observers/ApplicationResponseObserver.php +++ b/app/Observers/ApplicationResponseObserver.php @@ -1,19 +1,13 @@ getApplicationFormResponseRows()->forceDelete(); } -} \ No newline at end of file +} diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 119e0a85..5204bae2 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -2,15 +2,13 @@ namespace App\Providers; -use DB; -use App\ApplicationResponse; -use Illuminate\Database\Schema\Blueprint; -use Illuminate\Support\Fluent; use App\CustomClasses\MenuSingleton; -use App\Observers\ApplicationResponseObserver; use App\Setting; -use Illuminate\Support\ServiceProvider; +use Illuminate\Database\Schema\Blueprint; +use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Validator; +use Illuminate\Support\Fluent; +use Illuminate\Support\ServiceProvider; class AppServiceProvider extends ServiceProvider { @@ -21,7 +19,7 @@ class AppServiceProvider extends ServiceProvider */ public function boot() { - Validator::extend('recaptcha','App\\Validators\\ReCaptcha@validate'); + Validator::extend('recaptcha', 'App\\Validators\\ReCaptcha@validate'); } /** @@ -31,20 +29,21 @@ public function boot() */ public function register() { - $this->app->singleton(MenuSingleton::MENUSINGLETON, function() - { + $this->app->singleton(MenuSingleton::MENUSINGLETON, function () { return new MenuSingleton(); }); - $this->app->singleton(Setting::SINGELTONNAME, function() - { + $this->app->singleton(Setting::SINGELTONNAME, function () { $setting = new Setting(); $setting->initialise(); return $setting; }); - Blueprint::macro('dropForeignSilently', function($index): Fluent { - if (DB::getDriverName() === 'sqlite') return new Fluent(); + Blueprint::macro('dropForeignSilently', function ($index): Fluent { + if (DB::getDriverName() === 'sqlite') { + return new Fluent(); + } + return self::dropForeign($index); }); } diff --git a/app/Providers/AuthServiceProvider.php b/app/Providers/AuthServiceProvider.php index 9784b1a3..9e68caa6 100644 --- a/app/Providers/AuthServiceProvider.php +++ b/app/Providers/AuthServiceProvider.php @@ -2,7 +2,6 @@ namespace App\Providers; -use Illuminate\Support\Facades\Gate; use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider; class AuthServiceProvider extends ServiceProvider diff --git a/app/Providers/BroadcastServiceProvider.php b/app/Providers/BroadcastServiceProvider.php index 1dcf8d28..dc3007b5 100644 --- a/app/Providers/BroadcastServiceProvider.php +++ b/app/Providers/BroadcastServiceProvider.php @@ -2,8 +2,8 @@ namespace App\Providers; -use Illuminate\Support\ServiceProvider; use Illuminate\Support\Facades\Broadcast; +use Illuminate\Support\ServiceProvider; class BroadcastServiceProvider extends ServiceProvider { diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php index a182657e..0b7550a2 100644 --- a/app/Providers/EventServiceProvider.php +++ b/app/Providers/EventServiceProvider.php @@ -2,7 +2,6 @@ namespace App\Providers; -use Illuminate\Support\Facades\Event; use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider; class EventServiceProvider extends ServiceProvider diff --git a/app/Providers/MenuServiceProvider.php b/app/Providers/MenuServiceProvider.php index 8471afe0..05241224 100644 --- a/app/Providers/MenuServiceProvider.php +++ b/app/Providers/MenuServiceProvider.php @@ -24,8 +24,7 @@ public function boot() */ public function register() { - $this->app->singleton('MenuSingleton', function($app) - { + $this->app->singleton('MenuSingleton', function ($app) { return new MenuSingleton(); }); } diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php index 87ffb05a..b6fba644 100644 --- a/app/Providers/RouteServiceProvider.php +++ b/app/Providers/RouteServiceProvider.php @@ -2,8 +2,8 @@ namespace App\Providers; -use Illuminate\Support\Facades\Route; use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider; +use Illuminate\Support\Facades\Route; class RouteServiceProvider extends ServiceProvider { diff --git a/app/Providers/TelescopeServiceProvider.php b/app/Providers/TelescopeServiceProvider.php deleted file mode 100644 index 30dfd6c4..00000000 --- a/app/Providers/TelescopeServiceProvider.php +++ /dev/null @@ -1,65 +0,0 @@ -hideSensitiveRequestDetails(); - - Telescope::filter(function (IncomingEntry $entry) { - if (env('TELESCOPE_PROD', false) | $this->app->isLocal()) { - return true; - } - - return $entry->isReportableException() || - $entry->isFailedRequest() || - $entry->isFailedJob() || - $entry->isScheduledTask() || - $entry->hasMonitoredTag(); - }); - } - - /** - * Prevent sensitive request details from being logged by Telescope. - */ - protected function hideSensitiveRequestDetails(): void - { - if ($this->app->environment('local')) { - return; - } - - Telescope::hideRequestParameters(['_token']); - - Telescope::hideRequestHeaders([ - 'cookie', - 'x-csrf-token', - 'x-xsrf-token', - ]); - } - - /** - * Register the Telescope gate. - * - * This gate determines who can access Telescope in non-local environments. - */ - protected function gate(): void - { - Gate::define('viewTelescope', function ($user) { - return in_array($user->email, [ - 'whbles@gmail.com' - ]); - }); - } -} diff --git a/app/Repositories/AgendaItemCategorieRepository.php b/app/Repositories/AgendaItemCategorieRepository.php deleted file mode 100644 index 96be84a0..00000000 --- a/app/Repositories/AgendaItemCategorieRepository.php +++ /dev/null @@ -1,63 +0,0 @@ -_textRepository = $textRepository; - } - - public function create(array $data) - { - $text = $this->_textRepository->create($data); - - $agendaItemCategory = new AgendaItemCategorie(["name" => $text->id]); - $agendaItemCategory->save(); - - return $agendaItemCategory; - } - - public function update($id, array $data) - { - $agendaItemCategory = $this->find($id); - $this->_textRepository->update($agendaItemCategory->name, $data); - - return $agendaItemCategory; - } - - public function delete($id) - { - $agendaItemCategory = $this->find($id); - $agendaItemCategory->delete(); - $this->_textRepository->delete($agendaItemCategory->name); - - } - - public function find($id, $columns = array('*')) - { - return $this->findBy('id', $id, $columns)->first(); - } - - public function findBy($field, $value, $columns = array('*')) - { - return AgendaItemCategorie::where($field, '=',$value)->get($columns); - } - - public function all($columns = array('*')) - { - return AgendaItemCategorie::all($columns); - } -} \ No newline at end of file diff --git a/app/Repositories/AgendaItemCategoryRepository.php b/app/Repositories/AgendaItemCategoryRepository.php new file mode 100644 index 00000000..5891c53a --- /dev/null +++ b/app/Repositories/AgendaItemCategoryRepository.php @@ -0,0 +1,45 @@ +save(); + + return $agendaItemCategory; + } + + public function update($id, array $data) + { + $agendaItemCategory = $this->find($id); + $agendaItemCategory->update($data); + + return $agendaItemCategory; + } + + public function delete($id) + { + $agendaItemCategory = $this->find($id); + $agendaItemCategory->delete(); + } + + public function find($id, $columns = array('*')) + { + return $this->findBy('id', $id, $columns)->first(); + } + + public function findBy($field, $value, $columns = array('*')) + { + return AgendaItemCategory::where($field, '=',$value)->get($columns); + } + + public function all($columns = array('*')) + { + return AgendaItemCategory::all($columns); + } +} \ No newline at end of file diff --git a/app/Repositories/AgendaItemRepository.php b/app/Repositories/AgendaItemRepository.php index f21942bf..c06173ab 100644 --- a/app/Repositories/AgendaItemRepository.php +++ b/app/Repositories/AgendaItemRepository.php @@ -1,84 +1,60 @@ _textRepository = $_textRepository; - } - public function create(array $data) { - $title = $this->_textRepository->create(['NL_text' => $data['NL_title'], 'EN_text' => $data['EN_title']]); - $text = $this->_textRepository->create($data); - $shortDescription = $this->_textRepository->create(['NL_text' => $data['NL_shortDescription'], 'EN_text' => $data['EN_shortDescription']]); - $agendaItem = new AgendaItem($data); $starttime = new \DateTime($data['startDate']); $endtime = new \DateTime($data['endDate']); $subscription_endDate = new \DateTime($data['subscription_endDate']); - $agendaItem->startDate = Carbon::createFromFormat('d-m-Y H:i', $starttime->format('d-m-Y') . ' ' . $starttime->format('H:i')); - $agendaItem->endDate = Carbon::createFromFormat('d-m-Y H:i', $endtime->format('d-m-Y') . ' ' . $endtime->format('H:i')); - if($data['applicationForm'] != 0){ - $agendaItem->subscription_endDate = Carbon::createFromFormat('d-m-Y H:i', $subscription_endDate->format('d-m-Y') . ' ' . $subscription_endDate->format('H:i')); + $agendaItem->startDate = Carbon::createFromFormat('d-m-Y H:i', $starttime->format('d-m-Y') . ' ' . $starttime->format('H:i')); + $agendaItem->endDate = Carbon::createFromFormat('d-m-Y H:i', $endtime->format('d-m-Y') . ' ' . $endtime->format('H:i')); + + if ($data['applicationForm'] != 0) { + $agendaItem->subscription_endDate = Carbon::createFromFormat('d-m-Y H:i', $subscription_endDate->format('d-m-Y') . ' ' . $subscription_endDate->format('H:i')); $agendaItem->application_form_id = $data['applicationForm']; } else { $agendaItem->subscription_endDate = null; $agendaItem->application_form_id = null; } - $agendaItem->title = $title->id; - $agendaItem->text = $text->id; - $agendaItem->shortDescription = $shortDescription->id; $agendaItem->image_url = ""; - $agendaItem->createdBy = \Auth::user()->id; + $agendaItem->createdBy = Auth::user()->id; $agendaItem->climbing_activity = array_key_exists('climbing_activity', $data); $agendaItem->save(); + return $agendaItem; } public function update($id, array $data) { $agendaItem = $this->find($id); - - //update text - $this->_textRepository->update($agendaItem->title,['NL_text' => $data['NL_title'], 'EN_text' => $data['EN_title']]); - $this->_textRepository->update($agendaItem->text,$data); - $this->_textRepository->update($agendaItem->shortDescription,['NL_text' => $data['NL_shortDescription'], 'EN_text' => $data['EN_shortDescription']]); - + $agendaItem->title = $data['title']; + $agendaItem->text = $data['text']; + $agendaItem->shortDescription = $data['shortDescription']; + $agendaItem->category = $data['category']; $starttime = new \DateTime($data['startDate']); $endtime = new \DateTime($data['endDate']); $subscription_endDate = new \DateTime($data['subscription_endDate']); - $agendaItem->category = $data['category']; - $agendaItem->startDate = Carbon::createFromFormat('d-m-Y H:i', $starttime->format('d-m-Y') . ' ' . $starttime->format('H:i')); - $agendaItem->endDate = Carbon::createFromFormat('d-m-Y H:i', $endtime->format('d-m-Y') . ' ' . $endtime->format('H:i')); - if($data['applicationForm'] != 0){ - $agendaItem->subscription_endDate = Carbon::createFromFormat('d-m-Y H:i', $subscription_endDate->format('d-m-Y') . ' ' . $subscription_endDate->format('H:i')); + $agendaItem->startDate = Carbon::createFromFormat('d-m-Y H:i', $starttime->format('d-m-Y') . ' ' . $starttime->format('H:i')); + $agendaItem->endDate = Carbon::createFromFormat('d-m-Y H:i', $endtime->format('d-m-Y') . ' ' . $endtime->format('H:i')); + + if ($data['applicationForm'] != 0) { + $agendaItem->subscription_endDate = Carbon::createFromFormat('d-m-Y H:i', $subscription_endDate->format('d-m-Y') . ' ' . $subscription_endDate->format('H:i')); $agendaItem->application_form_id = $data['applicationForm']; } else { $agendaItem->subscription_endDate = null; $agendaItem->application_form_id = null; } + $agendaItem->climbing_activity = array_key_exists('climbing_activity', $data); $agendaItem->save(); @@ -90,22 +66,19 @@ public function delete($id) $agendaItem = $this->find($id); $agendaItem->delete(); - $this->_textRepository->delete($agendaItem->title); - $this->_textRepository->delete($agendaItem->text); - - if( $agendaItem->image_url != ""){ - \Storage::delete('public/'. $agendaItem->image_url); + if ($agendaItem->image_url != "") { + Storage::delete('public/' . $agendaItem->image_url); } } public function find($id, $columns = array('*')) { - return $this->findBy('id',$id,$columns); + return $this->findBy('id', $id, $columns); } public function findBy($field, $value, $columns = array('*')) { - return AgendaItem::query()->where($field,'=',$value)->first($columns); + return AgendaItem::query()->where($field, '=', $value)->first($columns); } public function all($columns = array('*')) @@ -113,49 +86,30 @@ public function all($columns = array('*')) return AgendaItem::all($columns); } - /** - * @param AgendaItem $agendaItem - * @return AgendaItem - */ public function copy(AgendaItem $agendaItem): AgendaItem { $newAgendaItem = $agendaItem->replicate(); - $newAgendaItem->createdBy = \Auth::user()->id; - - $title = $agendaItem->agendaItemTitle->replicate(); - $title->save(); - $text = $agendaItem->agendaItemText->replicate(); - $text->save(); - $shortDescription = $agendaItem->agendaItemShortDescription->replicate(); - $shortDescription->save(); - - $newAgendaItem->text = $text->id; - $newAgendaItem->title = $title->id; - $newAgendaItem->shortDescription = $shortDescription->id; + $newAgendaItem->createdBy = Auth::user()->id; $newAgendaItem->save(); - if ($agendaItem->image_url !== null && $agendaItem->image_url !== "") { + if ($agendaItem->image_url !== null && $agendaItem->image_url !== "") { $oldPath = $agendaItem->image_url; - $newPath = str_replace($agendaItem->id,$newAgendaItem->id, $oldPath); + $newPath = str_replace($agendaItem->id, $newAgendaItem->id, $oldPath); Storage::disk('public')->copy($oldPath, $newPath); $newAgendaItem->image_url = $newPath; $newAgendaItem->save(); } - return $newAgendaItem; } - /** - * Returns the first X amount of items from now - * @param $amount - */ - public function getFirstXItems($limit){ + public function getFirstXItems($limit) + { return AgendaItem::query() - ->with('agendaItemShortDescription','agendaItemTitle','getApplicationFormResponses') - ->whereDate('startDate','>=', Carbon::now()) + ->with('getApplicationFormResponses') + ->whereDate('startDate', '>=', Carbon::now()) ->orderBy('startDate', 'ASC') ->take($limit) ->get(); } -} \ No newline at end of file +} diff --git a/app/Repositories/ApplicationFormRepositories/ApplicationFormRegistrationRepository.php b/app/Repositories/ApplicationFormRepositories/ApplicationFormRegistrationRepository.php index e5b79f2c..257ac24c 100644 --- a/app/Repositories/ApplicationFormRepositories/ApplicationFormRegistrationRepository.php +++ b/app/Repositories/ApplicationFormRepositories/ApplicationFormRegistrationRepository.php @@ -24,18 +24,18 @@ public function storeRegistration(array $data, AgendaItem $agendaItem, int $user $applicationFormId = $agendaItem->application_form_id; - $applicationResponse->agenda_id = $agendaItem->id; + $applicationResponse->agenda_id = $agendaItem->id; $applicationResponse->inschrijf_form_id = $applicationFormId; - $applicationResponse->user_id = $userId; + $applicationResponse->user_id = $userId; $applicationResponse->save(); $applicationResponseId = $applicationResponse->id; //set the responserows foreach ($data as $key => $value) { - $applicationResponseRow = new ApplicationResponseRow(); + $applicationResponseRow = new ApplicationResponseRow(); $applicationResponseRow->application_response_id = $applicationResponseId; $applicationResponseRow->application_form_row_id = $key; - $applicationResponseRow->value = gettype($value) === 'array' ? implode(',', $value) : $value; + $applicationResponseRow->value = gettype($value) === 'array' ? implode(',', $value) : $value; $applicationResponseRow->save(); } } @@ -55,4 +55,4 @@ public function getApplicationInformation($agendaId, $userId): Collection return ApplicationResponseRow::where('application_response_id', $applicationResponse->id)->get(); } -} \ No newline at end of file +} diff --git a/app/Repositories/ApplicationFormRepositories/ApplicationFormRepository.php b/app/Repositories/ApplicationFormRepositories/ApplicationFormRepository.php index fe38e68b..fc84fed4 100644 --- a/app/Repositories/ApplicationFormRepositories/ApplicationFormRepository.php +++ b/app/Repositories/ApplicationFormRepositories/ApplicationFormRepository.php @@ -5,7 +5,6 @@ use App\Models\ApplicationForm\ApplicationForm; use App\Models\ApplicationForm\ApplicationFormRow; use App\Repositories\IRepository; -use App\Repositories\TextRepository; /** * Class ApplicationFormRepository @@ -13,10 +12,6 @@ */ class ApplicationFormRepository implements IRepository { - /** - * @var TextRepository - */ - private $textRepository; /** * @var ApplicationFormRowRepository */ @@ -24,14 +19,10 @@ class ApplicationFormRepository implements IRepository /** * AplicationFormRepository constructor. - * @param TextRepository $textRepository * @param ApplicationFormRowRepository $applicationFormRowRepository */ - public function __construct( - TextRepository $textRepository, - ApplicationFormRowRepository $applicationFormRowRepository + public function __construct(ApplicationFormRowRepository $applicationFormRowRepository ) { - $this->textRepository = $textRepository; $this->applicationFormRowRepository = $applicationFormRowRepository; } @@ -41,12 +32,7 @@ public function __construct( */ public function create(array $data): ApplicationForm { - $text = $this->textRepository->create([ - 'NL_text' => $data['nl_name'], - 'EN_text' => $data['en_name'] - ]); - - $applicationForm = new ApplicationForm(["name" => $text->id]); + $applicationForm = new ApplicationForm($data); $applicationForm->save(); if (array_key_exists('rows', $data) === true) { @@ -66,10 +52,7 @@ public function create(array $data): ApplicationForm public function update($id, array $data): ApplicationForm { $applicationForm = $this->find($id); - $this->textRepository->update($applicationForm->name, [ - 'NL_text' => $data['nl_name'], - 'EN_text' => $data['en_name'] - ]); + $applicationForm->update($data); $applicationFormRowIds = []; @@ -79,7 +62,7 @@ public function update($id, array $data): ApplicationForm $this->applicationFormRowRepository->update($rowData['id'], $rowData); $applicationFormRowIds[] = $rowData['id']; } else { - $applicationFormRow = $this + $applicationFormRow = $this ->applicationFormRowRepository ->create($applicationForm->id, $rowData); $applicationFormRowIds[] = $applicationFormRow->id; @@ -106,7 +89,6 @@ public function delete($id): void $this->applicationFormRowRepository->delete($row->id); } $applicationForm->delete(); - $this->textRepository->delete($applicationForm->name); } /** @@ -139,4 +121,4 @@ public function all($columns = array('*')) return ApplicationForm::all($columns); } -} \ No newline at end of file +} diff --git a/app/Repositories/ApplicationFormRepositories/ApplicationFormRowOptionRepository.php b/app/Repositories/ApplicationFormRepositories/ApplicationFormRowOptionRepository.php index 258aed47..5b730762 100644 --- a/app/Repositories/ApplicationFormRepositories/ApplicationFormRowOptionRepository.php +++ b/app/Repositories/ApplicationFormRepositories/ApplicationFormRowOptionRepository.php @@ -3,31 +3,13 @@ namespace App\Repositories\ApplicationFormRepositories; use App\Models\ApplicationForm\ApplicationFormRowOption; -use App\Repositories\TextRepository; class ApplicationFormRowOptionRepository { - /** - * @var TextRepository - */ - private $textRepository; - - /** - * ApplicationFormRowRepository constructor. - * @param TextRepository $textRepository - */ - public function __construct(TextRepository $textRepository) - { - $this->textRepository = $textRepository; - } - public function create(int $applicationFormRowId, array $data): ApplicationFormRowOption { - $text = $this->textRepository->create(['NL_text' => $data['nl_name'], 'EN_text' => $data['en_name']]); - $option = new ApplicationFormRowOption($data); $option->application_form_row_id = $applicationFormRowId; - $option->name_id = $text->id; $option->save(); return $option; @@ -36,12 +18,7 @@ public function create(int $applicationFormRowId, array $data): ApplicationFormR public function update($id, array $data) { $option = $this->find($id); - $this->textRepository->update($option->name_id, [ - 'NL_text' => $data['nl_name'], - 'EN_text' => $data['en_name'] - ]); - - $option->value = $data['value']; + $option->update($data); $option->save(); return $option; @@ -67,4 +44,4 @@ public function findBy($field, $value, $columns = array('*')) { return ApplicationFormRowOption::where($field, '=', $value)->get($columns); } -} \ No newline at end of file +} diff --git a/app/Repositories/ApplicationFormRepositories/ApplicationFormRowRepository.php b/app/Repositories/ApplicationFormRepositories/ApplicationFormRowRepository.php index 1255df7c..a9b0d231 100644 --- a/app/Repositories/ApplicationFormRepositories/ApplicationFormRowRepository.php +++ b/app/Repositories/ApplicationFormRepositories/ApplicationFormRowRepository.php @@ -10,7 +10,6 @@ use App\Models\ApplicationForm\ApplicationFormRow; use App\Models\ApplicationForm\ApplicationFormRowOption; -use App\Repositories\TextRepository; /** * Class ApplicationFormRowRepository @@ -18,11 +17,6 @@ */ class ApplicationFormRowRepository { - /** - * @var TextRepository - */ - private $textRepository; - /** * @var ApplicationFormRowOptionRepository */ @@ -30,12 +24,10 @@ class ApplicationFormRowRepository /** * ApplicationFormRowRepository constructor. - * @param TextRepository $textRepository * @param ApplicationFormRowOptionRepository $applicationFormRowOptionRepository */ - public function __construct(TextRepository $textRepository, ApplicationFormRowOptionRepository $applicationFormRowOptionRepository) + public function __construct(ApplicationFormRowOptionRepository $applicationFormRowOptionRepository) { - $this->textRepository = $textRepository; $this->applicationFormRowOptionRepository = $applicationFormRowOptionRepository; } @@ -45,9 +37,7 @@ public function __construct(TextRepository $textRepository, ApplicationFormRowOp */ public function create(int $formId, array $data): ApplicationFormRow { - $text = $this->textRepository->create(['NL_text' => $data['nl_name'], 'EN_text' => $data['en_name']]); $row = new ApplicationFormRow($data); - $row->name = $text->id; $row->application_form_id = $formId; $row->required = array_key_exists('required', $data); $row->save(); @@ -68,20 +58,14 @@ public function create(int $formId, array $data): ApplicationFormRow public function update(int $id, array $data): void { $row = $this->find($id); - $this->textRepository->update($row->name, [ - 'NL_text' => $data['nl_name'], - 'EN_text' => $data['en_name'] - ]); - - $row->type = $data['type']; - $row->required = array_key_exists('required', $data); + $row->update($data); $row->save(); $optionIds = []; if (array_key_exists('options', $data)) { foreach ($data['options'] as $optionData) { - if(array_key_exists('id', $optionData)) { + if (array_key_exists('id', $optionData)) { $option = $this->applicationFormRowOptionRepository->update($optionData['id'], $optionData); } else { $option = $this->applicationFormRowOptionRepository->create($row->id, $optionData); @@ -104,7 +88,6 @@ public function delete($id) $applicationFormRow = $this->find($id); if ($applicationFormRow != null) { $applicationFormRow->delete(); - $this->textRepository->delete($applicationFormRow->name); } } @@ -147,4 +130,4 @@ public function getRows($application_form_id) return $this->findBy('application_form_id', $application_form_id, $columns = array('*')); } -} \ No newline at end of file +} diff --git a/app/Repositories/BookRepository.php b/app/Repositories/BookRepository.php index 7fe6c23d..8c413589 100644 --- a/app/Repositories/BookRepository.php +++ b/app/Repositories/BookRepository.php @@ -6,10 +6,8 @@ class BookRepository implements IRepository { - public function create(array $data) { - $book = new Book($data); $book->save(); @@ -20,14 +18,12 @@ public function update($id, array $data) { $book = $this->find($id); $book->update($data); - return $book; } public function delete($id) { $book = $this->find($id); - $book->delete(); } @@ -38,11 +34,11 @@ public function find($id, $columns = array('*')) public function findBy($field, $value, $columns = array('*')) { - return Book::where($field, '=',$value)->get($columns); + return Book::where($field, '=', $value)->get($columns); } public function all($columns = array('*')) { - return Book::all($columns); + return Book::all(); } -} \ No newline at end of file +} diff --git a/app/Repositories/CertificateRepository.php b/app/Repositories/CertificateRepository.php index 14a7b285..e479b2e1 100644 --- a/app/Repositories/CertificateRepository.php +++ b/app/Repositories/CertificateRepository.php @@ -1,52 +1,31 @@ _textRepository = $textRepository; - } - public function create(array $data) { - $text = $this->_textRepository->create($data); - $Certificate = new Certificate($data); - $Certificate->name = $text->id; - $Certificate->duration = $data['duration'] === "" ? 0 : $data['duration']; - $Certificate->save(); + $certificate = new Certificate($data); + $certificate->save(); - return $Certificate; + return $certificate; } public function update($id, array $data) { - $data['duration'] = $data['duration'] === "" ? 0 : $data['duration']; - $Certificate = $this->find($id); - - $Certificate->update($data); - $this->_textRepository->update($Certificate->name, $data); + $certificate = $this->find($id); + $certificate->update($data); - return $Certificate; + return $certificate; } public function delete($id) { - $Certificate = $this->find($id); - $Certificate->delete(); - $this->_textRepository->delete($Certificate->name); + $certificate = $this->find($id); + $certificate->delete(); } public function find($id, $columns = array('*')) @@ -56,11 +35,11 @@ public function find($id, $columns = array('*')) public function findBy($field, $value, $columns = array('*')) { - return Certificate::where($field, '=',$value)->get($columns); + return Certificate::where($field, '=', $value)->get($columns); } public function all($columns = array('*')) { return Certificate::all(); } -} \ No newline at end of file +} diff --git a/app/Repositories/IRepository.php b/app/Repositories/IRepository.php index 89bd8649..13b59698 100644 --- a/app/Repositories/IRepository.php +++ b/app/Repositories/IRepository.php @@ -8,7 +8,6 @@ namespace App\Repositories; - interface IRepository { public function create(array $data); @@ -22,4 +21,4 @@ public function find($id, $columns = array('*')); public function findBy($field, $value, $columns = array('*')); public function all($columns = array('*')); -} \ No newline at end of file +} diff --git a/app/Repositories/MenuRepository.php b/app/Repositories/MenuRepository.php index da4ba20c..1d6896b3 100644 --- a/app/Repositories/MenuRepository.php +++ b/app/Repositories/MenuRepository.php @@ -1,34 +1,15 @@ _textRepository = $textRepository; - } - public function create(array $data) { - $name = $this->_textRepository->create($data); - $content = $this->_textRepository->create(['NL_text' => $data['content_nl'], 'EN_text' => $data['content_en']]); - $menuItem = new MenuItem(); - $menuItem->name= $name->id; - $menuItem->content_id= $content->id; - if($data['itemType'] === "subItem"){ + $menuItem = new MenuItem($data); + if ($data['itemType'] === "subItem") { $menuItem->parent_id = $data['parentItem']; } $menuItem->urlName = $data['urlName']; @@ -44,15 +25,14 @@ public function create(array $data) public function update($id, array $data) { $menuItem = $this->find($id); - $this->_textRepository->update($menuItem->name,$data); - $this->_textRepository->update($menuItem->content_id,['NL_text' => $data['content_nl'], 'EN_text' => $data['content_en']]); + $menuItem->update($data); - if($data['itemType'] === "subItem"){ + if ($data['itemType'] === "subItem") { $menuItem->parent_id = $data['parentItem']; } else { $menuItem->parent_id = null; } - if($menuItem->editable){ + if ($menuItem->editable) { $menuItem->urlName = $data['urlName']; } $menuItem->menuItem = array_key_exists("menuItem", $data); @@ -64,7 +44,7 @@ public function update($id, array $data) public function delete($id) { $menuItem = $this->find($id); - if($menuItem->deletable) { + if ($menuItem->deletable) { //delete refrences from the other menu items MenuItem::where('parent_id', $menuItem->id) ->update(['parent_id' => null]); @@ -72,23 +52,21 @@ public function delete($id) ->update(['after' => null]); $menuItem->delete(); - $this->_textRepository->delete($menuItem->name); - $this->_textRepository->delete($menuItem->content_id); } } public function find($id, $columns = array('*')) { - return $this->findBy('id',$id,$columns); + return $this->findBy('id', $id, $columns); } public function findBy($field, $value, $columns = array('*')) { - return MenuItem::query()->where($field,'=',$value)->first($columns); + return MenuItem::query()->where($field, '=', $value)->first($columns); } public function all($columns = array('*')) { return MenuItem::all($columns); } -} \ No newline at end of file +} diff --git a/app/Repositories/NewsItemRepository.php b/app/Repositories/NewsItemRepository.php index 4be480cf..a263e30e 100644 --- a/app/Repositories/NewsItemRepository.php +++ b/app/Repositories/NewsItemRepository.php @@ -8,33 +8,13 @@ namespace App\Repositories; - use App\NewsItem; class NewsItemRepository implements IRepository { - - private $_textRepository; - - /** - * NewsItemRepository constructor. - * @param $_textRepository - */ - public function __construct(TextRepository $_textRepository) - { - $this->_textRepository = $_textRepository; - } - public function create(array $data) { - $title = $this->_textRepository->create(['NL_text' => $data['NL_title'], 'EN_text' => $data['EN_title']]); - $text = $this->_textRepository->create($data); - - $newsItem = new NewsItem($data); - $newsItem->title = $title->id; - $newsItem->text = $text->id; - $newsItem->save(); - + $newsItem = NewsItem::create($data); return $newsItem; } @@ -43,10 +23,6 @@ public function update($id, array $data) $newsItem = $this->find($id); $newsItem->update($data); - //update text - $this->_textRepository->update($newsItem->title,['NL_text' => $data['NL_title'], 'EN_text' => $data['EN_title']]); - $this->_textRepository->update($newsItem->text,$data); - return $newsItem; } @@ -54,9 +30,6 @@ public function delete($id) { $newsItem = $this->find($id); $newsItem->delete(); - - $this->_textRepository->delete($newsItem->title); - $this->_textRepository->delete($newsItem->text); } public function find($id, $columns = array('*')) @@ -66,7 +39,7 @@ public function find($id, $columns = array('*')) public function findBy($field, $value, $columns = array('*')) { - return NewsItem::where($field, '=',$value)->get($columns); + return NewsItem::where($field, '=', $value)->get($columns); } public function all($columns = array('*')) @@ -74,7 +47,8 @@ public function all($columns = array('*')) return NewsItem::all($columns); } - public function getLastXNewsItems( $limit){ + public function getLastXNewsItems($limit) + { return NewsItem::orderBy('id', 'desc')->take($limit)->get(); } -} \ No newline at end of file +} diff --git a/app/Repositories/RepositorieFactory.php b/app/Repositories/RepositorieFactory.php deleted file mode 100644 index 286e3e8f..00000000 --- a/app/Repositories/RepositorieFactory.php +++ /dev/null @@ -1,55 +0,0 @@ -_repositoryList = [ - RepositorieFactory::$USERREPOKEY => new \App\Repositories\UserRepository(), - RepositorieFactory::$ROLREPOKEY => new RolRepository($textRepository), - RepositorieFactory::$TEXTREPOKEY => $textRepository, - RepositorieFactory::$MENUREPOKEY => new MenuRepository($textRepository), - RepositorieFactory::$CERTIFICATEREPOKEY => new CertificateRepository($textRepository), - RepositorieFactory::$AGENDAITEMREPOKEY => new AgendaItemRepository($textRepository), - RepositorieFactory::$AGENDAITEMRECATEGORYPOKEY => new AgendaItemCategorieRepository($textRepository), - RepositorieFactory::$NEWSITEMREPOKEY => new NewsItemRepository($textRepository), - RepositorieFactory::$ZEKERINGENREPOKEY => new ZekeringenRepository(), - RepositorieFactory::$BOOKREPOKEY => new BookRepository($textRepository), - ]; - } - - public function getRepositorie($type) - { - if (array_key_exists($type, $this->_repositoryList)) { - return $this->_repositoryList[$type]; - } else { - return null; - } - - } -} diff --git a/app/Repositories/RolRepository.php b/app/Repositories/RolRepository.php index 1f2e238f..27949b80 100644 --- a/app/Repositories/RolRepository.php +++ b/app/Repositories/RolRepository.php @@ -1,39 +1,22 @@ _textRepository = $textRepository; - } public function create(array $data) { - $text = $this->_textRepository->create($data); - - $rol = new Rol(["name" => $text->id]); - $rol->save(); - + $rol = Rol::create($data); return $rol; } public function update($id, array $data) { $rol = $this->find($id); - $this->_textRepository->update($rol->name, $data); + $rol->update($data); return $rol; } @@ -42,8 +25,6 @@ public function delete($id) { $rol = $this->find($id); $rol->delete(); - $this->_textRepository->delete($rol->name); - } public function find($id, $columns = array('*')) @@ -53,11 +34,11 @@ public function find($id, $columns = array('*')) public function findBy($field, $value, $columns = array('*')) { - return Rol::where($field, '=',$value)->get($columns); + return Rol::where($field, '=', $value)->get($columns); } public function all($columns = array('*')) { return Rol::all($columns); } -} \ No newline at end of file +} diff --git a/app/Repositories/TextRepository.php b/app/Repositories/TextRepository.php index 555cdf89..bfa982b3 100644 --- a/app/Repositories/TextRepository.php +++ b/app/Repositories/TextRepository.php @@ -8,7 +8,6 @@ namespace App\Repositories; - use App\Text; class TextRepository implements IRepository @@ -42,11 +41,11 @@ public function find($id, $columns = array('*')) public function findBy($field, $value, $columns = array('*')) { - return Text::where($field, '=',$value)->get($columns); + return Text::where($field, '=', $value)->get($columns); } public function all($columns = array('*')) { return Text::all($columns); } -} \ No newline at end of file +} diff --git a/app/Repositories/UserRepository.php b/app/Repositories/UserRepository.php index 608a4bc4..8dd043ec 100644 --- a/app/Repositories/UserRepository.php +++ b/app/Repositories/UserRepository.php @@ -92,9 +92,7 @@ public function addCertificate($userid, $data) { $user = $this->find($userid); - $starttime = new \DateTime($data['startDate']); - - $user->certificates()->attach($data['certificate_id'], ['startDate' => Carbon::createFromFormat('d-m-Y H:i', $data['startDate'] . ' ' . $starttime->format('H:i'))]); + $user->certificates()->attach($data['certificate_id']); } public function getUserCertificates($userid) diff --git a/app/Rol.php b/app/Rol.php index b344c86f..0a51a505 100644 --- a/app/Rol.php +++ b/app/Rol.php @@ -9,10 +9,6 @@ class Rol extends Model { use SoftDeletes; protected $fillable = [ - 'name' + 'name', ]; - - public function text(){ - return $this->hasOne('App\Text', 'id', 'name')->withTrashed(); - } } diff --git a/app/Rules/EmailDomainValidator.php b/app/Rules/EmailDomainValidator.php index 23cb6c19..09a3fb80 100644 --- a/app/Rules/EmailDomainValidator.php +++ b/app/Rules/EmailDomainValidator.php @@ -26,9 +26,9 @@ public function __construct() */ public function passes($attribute, $value) { - $splitEmail = explode("@",$value); + $splitEmail = explode("@", $value); - if(count($splitEmail) != 2) { + if (count($splitEmail) != 2) { return false; } @@ -45,6 +45,6 @@ public function passes($attribute, $value) */ public function message() { - return trans('validation.bannedEmailDomain'); + return 'Email addresses of educational institutions (student.tue.nl) are not allowed to make sure you can still receive our emails after you graduate'; } } diff --git a/app/Services/AgendaApplicationFormService.php b/app/Services/AgendaApplicationFormService.php index 0c853da6..73e327ad 100644 --- a/app/Services/AgendaApplicationFormService.php +++ b/app/Services/AgendaApplicationFormService.php @@ -31,8 +31,7 @@ public function getRegisteredUsers(AgendaItem $agendaItem): array // Map custom fields $customfields = $applicationForm->applicationFormRows - ->pluck('applicationFormRowName') - ->map->text() + ->pluck('name') ->all(); // Map user data @@ -41,7 +40,7 @@ public function getRegisteredUsers(AgendaItem $agendaItem): array $user["_signupId"] = $response->id; $response->getApplicationFormResponseRows->each(function ($responseRow) use (&$user) { - $columnname = $responseRow->getApplicationFormRow->applicationFormRowName->text(); + $columnname = $responseRow->getApplicationFormRow->name; $user[$columnname] = $responseRow->value; }); @@ -53,7 +52,7 @@ public function getRegisteredUsers(AgendaItem $agendaItem): array // Build the final array to return return [ - "agendaitem" => $agendaItem->agendaItemTitle->text(), + "agendaitem" => $agendaItem->title, "agendaId" => $agendaItem->id, "userdata" => $userdata, "customfields" => $customfields, diff --git a/app/Setting.php b/app/Setting.php index 7359ed7e..40b94e50 100644 --- a/app/Setting.php +++ b/app/Setting.php @@ -3,6 +3,7 @@ namespace App; use Illuminate\Database\Eloquent\Model; +use Illuminate\Support\Facades\Log; class Setting extends Model { @@ -23,21 +24,23 @@ class Setting extends Model protected $fillable = [ 'name', 'type', - 'value' + 'value', ]; - public function initialise(){ + public function initialise() + { $this->_settings = array(); - foreach (Setting::all() as $setting){ + foreach (Setting::all() as $setting) { $this->_settings[$setting->name] = $setting->value; } } - public function getSetting($name){ - if(array_key_exists($name,$this->_settings)){ + public function getSetting($name) + { + if (array_key_exists($name, $this->_settings)) { return $this->_settings[$name]; } else { - \Log::alert('Setting with the name: ' . $name . ' asked but not found in settings list!'); + Log::alert('Setting with the name: ' . $name . ' asked but not found in settings list!'); return ""; } } diff --git a/app/Text.php b/app/Text.php index 93da064d..1006e2c7 100644 --- a/app/Text.php +++ b/app/Text.php @@ -15,14 +15,15 @@ class Text extends Model */ protected $fillable = [ 'NL_text', - 'EN_text' + 'EN_text', ]; /** * @return mixed */ - public function text(){ - if(App::isLocale('en')){ + public function text() + { + if (App::isLocale('en')) { return $this->EN_text; } else { return $this->NL_text; diff --git a/app/User.php b/app/User.php index 2b4b2bf5..15d61792 100644 --- a/app/User.php +++ b/app/User.php @@ -61,7 +61,6 @@ public function roles() public function certificates() { return $this->belongsToMany('App\Certificate', 'certificate_user') - ->withPivot('startDate') ->withTimestamps()->withTrashed(); } diff --git a/app/Zekering.php b/app/Zekering.php index d645746b..2ee86a61 100644 --- a/app/Zekering.php +++ b/app/Zekering.php @@ -11,17 +11,19 @@ use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\SoftDeletes; -class Zekering extends Model { +class Zekering extends Model +{ use SoftDeletes; protected $fillable = [ 'text', 'createdBy', 'score', 'parent_id', - 'has_parent' + 'has_parent', ]; - public function children() { + public function children() + { return $this->hasMany(Zekering::class, 'parent_id', 'id')->where('id', '!=', 'parent_id')->orderBy('id', 'asc'); } } diff --git a/codecov.yml b/codecov.yml index d525463c..20073534 100644 --- a/codecov.yml +++ b/codecov.yml @@ -1,6 +1,11 @@ coverage: status: - project: + project: # Applies to the entire project default: target: auto - threshold: 30% + threshold: 25% # Allows coverage to drop by up to 30% without failing + + patch: # Applies only to the changes in the pull request + default: + target: auto + threshold: 25% # Allows coverage to drop by up to 30% without failing \ No newline at end of file diff --git a/composer.json b/composer.json index 3aac2fbd..4fad70d8 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,6 @@ "laravel/framework": "10.*", "laravel/helpers": "^1.6", "laravel/legacy-factories": "^1.3", - "laravel/telescope": "^4.15", "laravel/tinker": "^2.7", "laravel/ui": "^4.2", "laravelcollective/html": "^6.4", diff --git a/composer.lock b/composer.lock index b824b365..91a922d3 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "9f23159739e243f09739a0f8c8639928", + "content-hash": "03bc89e706a19ae3dd3a27f163338df6", "packages": [ { "name": "brick/math", @@ -2033,77 +2033,6 @@ }, "time": "2023-07-14T13:56:28+00:00" }, - { - "name": "laravel/telescope", - "version": "v4.16.4", - "source": { - "type": "git", - "url": "https://github.com/laravel/telescope.git", - "reference": "5cb73363ef6d57e4087ccc380964c5120d34ec3c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/laravel/telescope/zipball/5cb73363ef6d57e4087ccc380964c5120d34ec3c", - "reference": "5cb73363ef6d57e4087ccc380964c5120d34ec3c", - "shasum": "" - }, - "require": { - "ext-json": "*", - "laravel/framework": "^8.37|^9.0|^10.0", - "php": "^8.0", - "symfony/var-dumper": "^5.0|^6.0" - }, - "require-dev": { - "ext-gd": "*", - "guzzlehttp/guzzle": "^6.0|^7.0", - "laravel/octane": "^1.4", - "orchestra/testbench": "^6.0|^7.0|^8.0", - "phpstan/phpstan": "^1.10", - "phpunit/phpunit": "^9.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.x-dev" - }, - "laravel": { - "providers": [ - "Laravel\\Telescope\\TelescopeServiceProvider" - ] - } - }, - "autoload": { - "psr-4": { - "Laravel\\Telescope\\": "src/", - "Laravel\\Telescope\\Database\\Factories\\": "database/factories/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Taylor Otwell", - "email": "taylor@laravel.com" - }, - { - "name": "Mohamed Said", - "email": "mohamed@laravel.com" - } - ], - "description": "An elegant debug assistant for the Laravel framework.", - "keywords": [ - "debugging", - "laravel", - "monitoring" - ], - "support": { - "issues": "https://github.com/laravel/telescope/issues", - "source": "https://github.com/laravel/telescope/tree/v4.16.4" - }, - "time": "2023-09-25T13:48:25+00:00" - }, { "name": "laravel/tinker", "version": "v2.8.2", diff --git a/config/app.php b/config/app.php index 050833d4..24c83706 100644 --- a/config/app.php +++ b/config/app.php @@ -10,7 +10,7 @@ | This value is the name of your application. This value is used when the | framework needs to place the application's name in a notification or | any other location as required by the application or its packages. - */ + */ 'name' => 'ESAC', @@ -23,7 +23,7 @@ | running in. This may determine how you prefer to configure various | services your application utilizes. Set this in your ".env" file. | - */ + */ 'env' => env('APP_ENV', 'production'), @@ -36,7 +36,7 @@ | stack traces will be shown on every error that occurs within your | application. If disabled, a simple generic error page is shown. | - */ + */ 'debug' => env('APP_DEBUG', false), @@ -49,7 +49,7 @@ | the Artisan command line tool. You should set this to the root of | your application so that it is used when running Artisan tasks. | - */ + */ 'url' => env('APP_URL', 'http://localhost'), @@ -62,7 +62,7 @@ | will be used by the PHP date and date-time functions. We have gone | ahead and set this to a sensible default for you out of the box. | - */ + */ 'timezone' => 'UTC', @@ -75,9 +75,9 @@ | by the translation service provider. You are free to set this value | to any of the locales which will be supported by the application. | - */ + */ - 'locale' => 'nl', + 'locale' => 'en', /* |-------------------------------------------------------------------------- @@ -88,9 +88,9 @@ | is not available. You may change the value to correspond to any of | the language folders that are provided through your application. | - */ + */ - 'fallback_locale' => 'nl', + 'fallback_locale' => 'en', /* |-------------------------------------------------------------------------- @@ -101,7 +101,7 @@ | to a random, 32 character string, otherwise these encrypted strings | will not be safe. Please do this before deploying an application! | - */ + */ 'key' => env('APP_KEY'), @@ -116,7 +116,7 @@ | request to your application. Feel free to add your own services to | this array to grant expanded functionality to your applications. | - */ + */ 'providers' => [ @@ -161,7 +161,6 @@ // App\Providers\BroadcastServiceProvider::class, App\Providers\EventServiceProvider::class, App\Providers\RouteServiceProvider::class, - App\Providers\TelescopeServiceProvider::class, Maatwebsite\Excel\ExcelServiceProvider::class, ], @@ -174,7 +173,7 @@ | is started. However, feel free to register as many as you wish as | the aliases are "lazy" loaded so they don't hinder performance. | - */ + */ 'aliases' => [ @@ -213,6 +212,6 @@ 'Form' => Collective\Html\FormFacade::class, 'Html' => Collective\Html\HtmlFacade::class, 'Excel' => Maatwebsite\Excel\Facades\Excel::class, - ], + ], ]; diff --git a/config/telescope.php b/config/telescope.php deleted file mode 100644 index 9a09fda1..00000000 --- a/config/telescope.php +++ /dev/null @@ -1,187 +0,0 @@ - env('TELESCOPE_DOMAIN'), - - /* - |-------------------------------------------------------------------------- - | Telescope Path - |-------------------------------------------------------------------------- - | - | This is the URI path where Telescope will be accessible from. Feel free - | to change this path to anything you like. Note that the URI will not - | affect the paths of its internal API that aren't exposed to users. - | - */ - - 'path' => env('TELESCOPE_PATH', 'telescope'), - - /* - |-------------------------------------------------------------------------- - | Telescope Storage Driver - |-------------------------------------------------------------------------- - | - | This configuration options determines the storage driver that will - | be used to store Telescope's data. In addition, you may set any - | custom options as needed by the particular driver you choose. - | - */ - - 'driver' => env('TELESCOPE_DRIVER', 'database'), - - 'storage' => [ - 'database' => [ - 'connection' => env('DB_CONNECTION', 'mysql'), - 'chunk' => 1000, - ], - ], - - /* - |-------------------------------------------------------------------------- - | Telescope Master Switch - |-------------------------------------------------------------------------- - | - | This option may be used to disable all Telescope watchers regardless - | of their individual configuration, which simply provides a single - | and convenient way to enable or disable Telescope data storage. - | - */ - - 'enabled' => env('TELESCOPE_ENABLED', true), - - /* - |-------------------------------------------------------------------------- - | Telescope Route Middleware - |-------------------------------------------------------------------------- - | - | These middleware will be assigned to every Telescope route, giving you - | the chance to add your own middleware to this list or change any of - | the existing middleware. Or, you can simply stick with this list. - | - */ - - 'middleware' => [ - 'web', - Authorize::class, - ], - - /* - |-------------------------------------------------------------------------- - | Allowed / Ignored Paths & Commands - |-------------------------------------------------------------------------- - | - | The following array lists the URI paths and Artisan commands that will - | not be watched by Telescope. In addition to this list, some Laravel - | commands, like migrations and queue commands, are always ignored. - | - */ - - 'only_paths' => [ - // 'api/*' - ], - - 'ignore_paths' => [ - 'nova-api*', - ], - - 'ignore_commands' => [ - // - ], - - /* - |-------------------------------------------------------------------------- - | Telescope Watchers - |-------------------------------------------------------------------------- - | - | The following array lists the "watchers" that will be registered with - | Telescope. The watchers gather the application's profile data when - | a request or task is executed. Feel free to customize this list. - | - */ - - 'watchers' => [ - Watchers\BatchWatcher::class => env('TELESCOPE_BATCH_WATCHER', true), - - Watchers\CacheWatcher::class => [ - 'enabled' => env('TELESCOPE_CACHE_WATCHER', true), - 'hidden' => [], - ], - - Watchers\ClientRequestWatcher::class => env('TELESCOPE_CLIENT_REQUEST_WATCHER', true), - - Watchers\CommandWatcher::class => [ - 'enabled' => env('TELESCOPE_COMMAND_WATCHER', true), - 'ignore' => [], - ], - - Watchers\DumpWatcher::class => [ - 'enabled' => env('TELESCOPE_DUMP_WATCHER', true), - 'always' => env('TELESCOPE_DUMP_WATCHER_ALWAYS', false), - ], - - Watchers\EventWatcher::class => [ - 'enabled' => env('TELESCOPE_EVENT_WATCHER', true), - 'ignore' => [], - ], - - Watchers\ExceptionWatcher::class => env('TELESCOPE_EXCEPTION_WATCHER', true), - - Watchers\GateWatcher::class => [ - 'enabled' => env('TELESCOPE_GATE_WATCHER', true), - 'ignore_abilities' => [], - 'ignore_packages' => true, - 'ignore_paths' => [], - ], - - Watchers\JobWatcher::class => env('TELESCOPE_JOB_WATCHER', true), - - Watchers\LogWatcher::class => [ - 'enabled' => env('TELESCOPE_LOG_WATCHER', true), - 'level' => 'error', - ], - - Watchers\MailWatcher::class => env('TELESCOPE_MAIL_WATCHER', true), - - Watchers\ModelWatcher::class => [ - 'enabled' => env('TELESCOPE_MODEL_WATCHER', true), - 'events' => ['eloquent.*'], - 'hydrations' => true, - ], - - Watchers\NotificationWatcher::class => env('TELESCOPE_NOTIFICATION_WATCHER', true), - - Watchers\QueryWatcher::class => [ - 'enabled' => env('TELESCOPE_QUERY_WATCHER', true), - 'ignore_packages' => true, - 'ignore_paths' => [], - 'slow' => 100, - ], - - Watchers\RedisWatcher::class => env('TELESCOPE_REDIS_WATCHER', true), - - Watchers\RequestWatcher::class => [ - 'enabled' => env('TELESCOPE_REQUEST_WATCHER', true), - 'size_limit' => env('TELESCOPE_RESPONSE_SIZE_LIMIT', 64), - 'ignore_http_methods' => [], - 'ignore_status_codes' => [], - ], - - Watchers\ScheduleWatcher::class => env('TELESCOPE_SCHEDULE_WATCHER', true), - Watchers\ViewWatcher::class => env('TELESCOPE_VIEW_WATCHER', true), - ], -]; diff --git a/database/factories/AgendaItemCategoryFactory.php b/database/factories/AgendaItemCategoryFactory.php index 2e07d971..4b4fe1f7 100644 --- a/database/factories/AgendaItemCategoryFactory.php +++ b/database/factories/AgendaItemCategoryFactory.php @@ -2,13 +2,11 @@ namespace Database\Factories; -use App\Text; -use App\AgendaItemCategorie; +use App\AgendaItemCategory; use Faker\Generator as Faker; -$factory->define(AgendaItemCategorie::class, function (Faker $faker) { - $text = factory(Text::class)->create(); +$factory->define(AgendaItemCategory::class, function (Faker $faker) { return [ - 'name' => $text->id + 'name' => $faker->word, ]; -}); \ No newline at end of file +}); diff --git a/database/factories/AgendaItemFactory.php b/database/factories/AgendaItemFactory.php index acc94a0d..9537c023 100644 --- a/database/factories/AgendaItemFactory.php +++ b/database/factories/AgendaItemFactory.php @@ -2,23 +2,19 @@ namespace Database\Factories; -use App\User; -use App\Text; use App\AgendaItem; -use App\AgendaItemCategorie; +use App\AgendaItemCategory; +use App\User; use Faker\Generator as Faker; $factory->define(AgendaItem::class, function (Faker $faker) { - $title = factory(Text::class)->create(); - $text = factory(Text::class)->create(); - $shortDescription = factory(Text::class)->create(); $user = factory(User::class)->create(); - $category = factory(AgendaItemCategorie::class)->create(); + $category = factory(AgendaItemCategory::class)->create(); return [ - 'title' => $title->id, - 'text'=> $text->id, - 'shortDescription' => $shortDescription->id, + 'title' => $faker->word, + 'text'=> $faker->text, + 'shortDescription' => $faker->word, 'createdBy' => $user->id, 'category' => $category->id, 'startDate' => $faker->date, diff --git a/database/factories/ApplicationFormFactory.php b/database/factories/ApplicationFormFactory.php index deb863cc..9e9968e3 100644 --- a/database/factories/ApplicationFormFactory.php +++ b/database/factories/ApplicationFormFactory.php @@ -3,13 +3,10 @@ namespace Database\Factories; use App\Models\ApplicationForm\ApplicationForm; -use App\Text; use Faker\Generator as Faker; -use Illuminate\Database\Eloquent\Factory; $factory->define(ApplicationForm::class, function (Faker $faker) { - $text = \factory(Text::class)->create(); return [ - 'name' => $text->id + 'name' => $faker->word, ]; }); diff --git a/database/factories/ApplicationFormRowFactory.php b/database/factories/ApplicationFormRowFactory.php index 706f3a31..86da14dc 100644 --- a/database/factories/ApplicationFormRowFactory.php +++ b/database/factories/ApplicationFormRowFactory.php @@ -4,14 +4,12 @@ use App\Models\ApplicationForm\ApplicationForm; use App\Models\ApplicationForm\ApplicationFormRow; -use App\Text; use Faker\Generator as Faker; $factory->define(ApplicationFormRow::class, function (Faker $faker) { $form = factory(ApplicationForm::class)->create(); - $text = factory(Text::class)->create(); return [ - 'name' => $text->id, + 'name' => $faker->word, 'application_form_id' => $form->id, 'type' => $faker->randomElement([ ApplicationFormRow::FORM_TYPE_CHECK_BOX, @@ -21,6 +19,6 @@ ApplicationFormRow::FORM_TYPE_TEXT, ApplicationFormRow::FORM_TYPE_TEXT_BOX, ]), - 'required' => $faker->boolean + 'required' => $faker->boolean, ]; }); diff --git a/database/factories/ApplicationFormRowOptionFactory.php b/database/factories/ApplicationFormRowOptionFactory.php index 89710b23..5b37b33f 100644 --- a/database/factories/ApplicationFormRowOptionFactory.php +++ b/database/factories/ApplicationFormRowOptionFactory.php @@ -4,15 +4,13 @@ use App\Models\ApplicationForm\ApplicationFormRow; use App\Models\ApplicationForm\ApplicationFormRowOption; -use App\Text; use Faker\Generator as Faker; $factory->define(ApplicationFormRowOption::class, function (Faker $faker) { - $text = factory(Text::class)->create(); $row = factory(ApplicationFormRow::class)->create(); return [ 'value' => $faker->word, - 'name_id' => $text->id, + 'name' => $faker->word, 'application_form_row_id' => $row->id, ]; }); diff --git a/database/factories/ApplicationResponseFactory.php b/database/factories/ApplicationResponseFactory.php index 43ddf164..824c6bbe 100644 --- a/database/factories/ApplicationResponseFactory.php +++ b/database/factories/ApplicationResponseFactory.php @@ -3,7 +3,6 @@ namespace Database\Factories; use App\AgendaItem; -use App\Model; use App\Models\ApplicationForm\ApplicationForm; use App\Models\ApplicationForm\ApplicationResponse; use App\User; diff --git a/database/factories/NewsItemFactory.php b/database/factories/NewsItemFactory.php index 286fe59b..7338effa 100644 --- a/database/factories/NewsItemFactory.php +++ b/database/factories/NewsItemFactory.php @@ -2,14 +2,13 @@ namespace Database\Factories; -use Faker\Generator as Faker; use App\NewsItem; -use App\Text; +use Faker\Generator as Faker; $factory->define(NewsItem::class, function (Faker $faker) { return [ - 'title' => factory(Text::class)->create(), - 'text' => factory(Text::class)->create(), + 'title' => $faker->title, + 'text' => $faker->text, 'image_url' =>$faker->imageUrl, 'thumbnail_url' => $faker->imageUrl, 'author' => $faker->firstName diff --git a/database/factories/RoleFactory.php b/database/factories/RoleFactory.php index ef8dad4e..c6f881df 100644 --- a/database/factories/RoleFactory.php +++ b/database/factories/RoleFactory.php @@ -3,12 +3,10 @@ namespace Database\Factories; use App\Rol; -use App\Text; use Faker\Generator as Faker; $factory->define(Rol::class, function (Faker $faker) { - $text = factory(Text::class)->create(); return [ - 'name' => $text->id + 'name' => $faker->word, ]; }); diff --git a/database/factories/UserFactory.php b/database/factories/UserFactory.php index 843b2e77..59d4e7c9 100644 --- a/database/factories/UserFactory.php +++ b/database/factories/UserFactory.php @@ -30,6 +30,6 @@ 'IBAN' => $faker->iban(), 'BIC' => $faker->bankAccountNumber, 'incasso' => $faker->boolean, - 'remark' => $faker->sentence + 'remark' => $faker->sentence, ]; }); diff --git a/database/migrations/2023_10_09_144100_set_english_text_default_agenda.php b/database/migrations/2023_10_09_144100_set_english_text_default_agenda.php new file mode 100644 index 00000000..9d26b2f2 --- /dev/null +++ b/database/migrations/2023_10_09_144100_set_english_text_default_agenda.php @@ -0,0 +1,76 @@ +string('title_string')->charset('utf8mb4')->collation('utf8mb4_unicode_ci'); + $table->longText('text_string')->charset('utf8mb4')->collation('utf8mb4_unicode_ci'); + $table->string('shortDescription_string')->charset('utf8mb4')->collation('utf8mb4_unicode_ci'); + }); + + // Migrate data from texts table to agenda_items. + $agendaItems = AgendaItem::all(); + foreach ($agendaItems as $item) { + $title = Text::find($item->title); + $text = Text::find($item->text); + $shortDescription = Text::find($item->shortDescription); + + $item->title_string = $title ? $title->EN_text : 'ERROR: TEXT NOT FOUND'; + $item->text_string = $text ? $text->EN_text : 'ERROR: TEXT NOT FOUND'; + $item->shortDescription_string = $shortDescription ? $shortDescription->EN_text : 'ERROR: TEXT NOT FOUND'; + + $item->save(); + } + + // Now we'll drop the old columns and foreign keys. + Schema::table('agenda_items', function (Blueprint $table) { + $table->dropForeign(['title']); + $table->dropForeign(['text']); + $table->dropForeign(['shortDescription']); + + $table->dropColumn('title'); + $table->dropColumn('text'); + $table->dropColumn('shortDescription'); + + }); + + DB::statement("ALTER TABLE agenda_items CHANGE title_string title VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci"); + DB::statement("ALTER TABLE agenda_items CHANGE text_string text LONGTEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci"); + DB::statement("ALTER TABLE agenda_items CHANGE shortDescription_string shortDescription VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci"); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('agenda_items', function (Blueprint $table) { + $table->dropColumn('title'); + $table->dropColumn('text'); + $table->dropColumn('shortDescription'); + }); + + Schema::table('agenda_items', function (Blueprint $table) { + $table->integer('title')->unsigned()->nullable(); + $table->integer('text')->unsigned()->nullable(); + $table->integer('shortDescription')->unsigned()->nullable(); + + $table->foreign('title')->references('id')->on('texts')->onDelete('set null'); + $table->foreign('text')->references('id')->on('texts')->onDelete('set null'); + $table->foreign('shortDescription')->references('id')->on('texts')->onDelete('set null'); + }); + } +} diff --git a/database/migrations/2023_10_09_151123_set_english_text_default_agenda_categories.php b/database/migrations/2023_10_09_151123_set_english_text_default_agenda_categories.php new file mode 100644 index 00000000..82b21590 --- /dev/null +++ b/database/migrations/2023_10_09_151123_set_english_text_default_agenda_categories.php @@ -0,0 +1,54 @@ +string('name_string')->charset('utf8mb4')->collation('utf8mb4_unicode_ci'); + }); + + // Migrate data from texts table to agenda_items categories. + $agendaItemCategories = AgendaItemCategory::all(); + foreach ($agendaItemCategories as $item) { + $name = Text::find($item->name); + $item->name_string = $name ? $name->EN_text : 'ERROR: TEXT NOT FOUND'; + $item->save(); + } + + // Now drop the foreign keys and original columns, then rename the new columns. + Schema::table('agenda_item_categories', function (Blueprint $table) { + $table->dropForeign(['name']); + $table->dropColumn('name'); + }); + + DB::statement("ALTER TABLE agenda_item_categories CHANGE name_string name VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci"); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('agenda_item_categories', function (Blueprint $table) { + + $table->dropColumn('name'); + }); + + Schema::table('agenda_item_categories', function (Blueprint $table) { + $table->integer('name')->unsigned()->nullable(); + $table->foreign('name')->references('id')->on('texts')->onDelete('set null'); + }); + } +}; diff --git a/database/migrations/2023_10_09_223615_set_english_text_default_application_form.php b/database/migrations/2023_10_09_223615_set_english_text_default_application_form.php new file mode 100644 index 00000000..5b8f6546 --- /dev/null +++ b/database/migrations/2023_10_09_223615_set_english_text_default_application_form.php @@ -0,0 +1,54 @@ +string('name_string')->charset('utf8mb4')->collation('utf8mb4_unicode_ci'); + }); + + // Migrate data from texts table to agenda_items categories. + $items = ApplicationForm::all(); + foreach ($items as $item) { + $name = Text::find($item->name); + $item->name_string = $name ? $name->EN_text : 'ERROR: TEXT NOT FOUND'; + $item->save(); + } + + // Now drop the foreign keys and original columns, then rename the new columns. + Schema::table('application_forms', function (Blueprint $table) { + $table->dropForeign(['name']); + $table->dropColumn('name'); + }); + + DB::statement("ALTER TABLE application_forms CHANGE name_string name VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci"); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('application_forms', function (Blueprint $table) { + + $table->dropColumn('name'); + }); + + Schema::table('application_forms', function (Blueprint $table) { + $table->integer('name')->unsigned()->nullable(); + $table->foreign('name')->references('id')->on('texts')->onDelete('set null'); + }); + } +}; diff --git a/database/migrations/2023_10_09_223615_set_english_text_default_application_form_row.php b/database/migrations/2023_10_09_223615_set_english_text_default_application_form_row.php new file mode 100644 index 00000000..7c58f00f --- /dev/null +++ b/database/migrations/2023_10_09_223615_set_english_text_default_application_form_row.php @@ -0,0 +1,54 @@ +string('name_string')->charset('utf8mb4')->collation('utf8mb4_unicode_ci'); + }); + + // Migrate data from texts table to agenda_items categories. + $items = ApplicationFormRow::all(); + foreach ($items as $item) { + $name = Text::find($item->name); + $item->name_string = $name ? $name->EN_text : 'ERROR: TEXT NOT FOUND'; + $item->save(); + } + + // Now drop the foreign keys and original columns, then rename the new columns. + Schema::table('application_form_rows', function (Blueprint $table) { + $table->dropForeign(['name']); + $table->dropColumn('name'); + }); + + DB::statement("ALTER TABLE application_form_rows CHANGE name_string name VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci"); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('application_form_rows', function (Blueprint $table) { + + $table->dropColumn('name'); + }); + + Schema::table('application_form_rows', function (Blueprint $table) { + $table->integer('name')->unsigned()->nullable(); + $table->foreign('name')->references('id')->on('texts')->onDelete('set null'); + }); + } +}; diff --git a/database/migrations/2023_10_09_223615_set_english_text_default_application_form_row_options.php b/database/migrations/2023_10_09_223615_set_english_text_default_application_form_row_options.php new file mode 100644 index 00000000..99ebaaad --- /dev/null +++ b/database/migrations/2023_10_09_223615_set_english_text_default_application_form_row_options.php @@ -0,0 +1,59 @@ +string('name_string'); + }); + + // Migrate data from texts table to agenda_items categories. + $items = ApplicationFormRowOption::all(); + foreach ($items as $item) { + $name = Text::find($item->name_id); + $name = $name ? $name->EN_text : 'ERROR: TEXT NOT FOUND'; + if (strlen($name) > 255) { + echo "Text is longer than 255 characters: " . $item->id . "\n"; + #truncate text to 255 characters + $name = substr($name, 0, 255); + } + $item->name_string = $name; + $item->save(); + } + + // Now drop the foreign keys and original columns, then rename the new columns. + Schema::table('application_form_row_options', function (Blueprint $table) { + $table->dropForeign(['name_id']); + $table->dropColumn('name_id'); + }); + + DB::statement("ALTER TABLE application_form_row_options CHANGE name_string name VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci"); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('application_form_row_options', function (Blueprint $table) { + $table->dropColumn('name'); + }); + + Schema::table('application_form_row_options', function (Blueprint $table) { + $table->integer('name_id')->unsigned()->nullable(); + $table->foreign('name_id')->references('id')->on('texts')->onDelete('set null'); + }); + } +}; diff --git a/database/migrations/2023_10_09_223615_set_english_text_default_certificates.php b/database/migrations/2023_10_09_223615_set_english_text_default_certificates.php new file mode 100644 index 00000000..7f433968 --- /dev/null +++ b/database/migrations/2023_10_09_223615_set_english_text_default_certificates.php @@ -0,0 +1,54 @@ +string('name_string')->charset('utf8mb4')->collation('utf8mb4_unicode_ci'); + }); + + // Migrate data from texts table to agenda_items categories. + $certificates = Certificate::all(); + foreach ($certificates as $item) { + $name = Text::find($item->name); + $item->name_string = $name ? $name->EN_text : 'ERROR: TEXT NOT FOUND'; + $item->save(); + } + + // Now drop the foreign keys and original columns, then rename the new columns. + Schema::table('certificates', function (Blueprint $table) { + $table->dropForeign(['name']); + $table->dropColumn('name'); + }); + + DB::statement("ALTER TABLE certificates CHANGE name_string name VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci"); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('certificates', function (Blueprint $table) { + + $table->dropColumn('name'); + }); + + Schema::table('certificates', function (Blueprint $table) { + $table->integer('name')->unsigned()->nullable(); + $table->foreign('name')->references('id')->on('texts')->onDelete('set null'); + }); + } +}; diff --git a/database/migrations/2023_10_09_223615_set_english_text_default_news.php b/database/migrations/2023_10_09_223615_set_english_text_default_news.php new file mode 100644 index 00000000..f8b11c50 --- /dev/null +++ b/database/migrations/2023_10_09_223615_set_english_text_default_news.php @@ -0,0 +1,62 @@ +string('title_string')->charset('utf8mb4')->collation('utf8mb4_unicode_ci'); + $table->longText('text_string')->charset('utf8mb4')->collation('utf8mb4_unicode_ci'); + }); + + // Migrate data from texts table to agenda_items categories. + $news_items = NewsItem::all(); + foreach ($news_items as $item) { + $title = Text::find($item->title); + $text = Text::find($item->text); + $item->title_string = $title ? $title->EN_text : 'ERROR: TEXT NOT FOUND'; + $item->text_string = $text ? $text->EN_text : 'ERROR: TEXT NOT FOUND'; + $item->save(); + } + + // Now drop the foreign keys and original columns, then rename the new columns. + Schema::table('news_items', function (Blueprint $table) { + $table->dropForeign(['title']); + $table->dropForeign(['text']); + $table->dropColumn('title'); + $table->dropColumn('text'); + }); + + DB::statement("ALTER TABLE news_items CHANGE title_string title VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci"); + DB::statement("ALTER TABLE news_items CHANGE text_string text LONGTEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci"); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('news_items', function (Blueprint $table) { + $table->dropColumn('title'); + $table->dropColumn('text'); + }); + + Schema::table('news_items', function (Blueprint $table) { + $table->integer('title')->unsigned()->nullable(); + $table->integer('text')->unsigned()->nullable(); + $table->foreign('title')->references('id')->on('texts')->onDelete('set null'); + $table->foreign('text')->references('id')->on('texts')->onDelete('set null'); + }); + } +}; diff --git a/database/migrations/2023_10_09_223615_set_english_text_default_page.php b/database/migrations/2023_10_09_223615_set_english_text_default_page.php new file mode 100644 index 00000000..738ce7d8 --- /dev/null +++ b/database/migrations/2023_10_09_223615_set_english_text_default_page.php @@ -0,0 +1,62 @@ +string('name_string')->charset('utf8mb4')->collation('utf8mb4_unicode_ci'); + $table->longText('content_string')->charset('utf8mb4')->collation('utf8mb4_unicode_ci'); + }); + + // Migrate data from texts table to agenda_items categories. + $menu_items = MenuItem::all(); + foreach ($menu_items as $item) { + $name = Text::find($item->name); + $content = Text::find($item->content_id); + $item->name_string = $name ? $name->EN_text : 'ERROR: TEXT NOT FOUND'; + $item->content_string = $content ? $content->EN_text : 'ERROR: TEXT NOT FOUND'; + $item->save(); + } + + // Now drop the foreign keys and original columns, then rename the new columns. + Schema::table('menu_items', function (Blueprint $table) { + $table->dropForeign(['name']); + $table->dropForeign(['content_id']); + $table->dropColumn('name'); + $table->dropColumn('content_id'); + }); + + DB::statement("ALTER TABLE menu_items CHANGE name_string name VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci"); + DB::statement("ALTER TABLE menu_items CHANGE content_string content LONGTEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci"); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('menu_items', function (Blueprint $table) { + $table->dropColumn('name'); + $table->dropColumn('content'); + }); + + Schema::table('menu_items', function (Blueprint $table) { + $table->integer('name')->unsigned()->nullable(); + $table->integer('content_id')->unsigned()->nullable(); + $table->foreign('name')->references('id')->on('texts')->onDelete('set null'); + $table->foreign('content_id')->references('id')->on('texts')->onDelete('set null'); + }); + } +}; diff --git a/database/migrations/2023_10_09_223615_set_english_text_default_role.php b/database/migrations/2023_10_09_223615_set_english_text_default_role.php new file mode 100644 index 00000000..e16a8219 --- /dev/null +++ b/database/migrations/2023_10_09_223615_set_english_text_default_role.php @@ -0,0 +1,54 @@ +string('name_string')->charset('utf8mb4')->collation('utf8mb4_unicode_ci'); + }); + + // Migrate data from texts table to agenda_items categories. + $roles = Rol::all(); + foreach ($roles as $item) { + $name = Text::find($item->name); + $item->name_string = $name ? $name->EN_text : 'ERROR: TEXT NOT FOUND'; + $item->save(); + } + + // Now drop the foreign keys and original columns, then rename the new columns. + Schema::table('rols', function (Blueprint $table) { + $table->dropForeign(['name']); + $table->dropColumn('name'); + }); + + DB::statement("ALTER TABLE rols CHANGE name_string name VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci"); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('rols', function (Blueprint $table) { + + $table->dropColumn('name'); + }); + + Schema::table('rols', function (Blueprint $table) { + $table->integer('name')->unsigned()->nullable(); + $table->foreign('name')->references('id')->on('texts')->onDelete('set null'); + }); + } +}; diff --git a/database/migrations/2023_10_11_143010_remove_certificate_start_date.php b/database/migrations/2023_10_11_143010_remove_certificate_start_date.php new file mode 100644 index 00000000..8c7f021f --- /dev/null +++ b/database/migrations/2023_10_11_143010_remove_certificate_start_date.php @@ -0,0 +1,28 @@ +dropColumn('startDate'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('certificate_user', function (Blueprint $table) { + $table->date('startDate')->nullable(); + }); + } +}; diff --git a/database/migrations/2023_10_18_172952_application_form_response_row_longtext.php b/database/migrations/2023_10_18_172952_application_form_response_row_longtext.php index 2e302b59..3e79cb26 100644 --- a/database/migrations/2023_10_18_172952_application_form_response_row_longtext.php +++ b/database/migrations/2023_10_18_172952_application_form_response_row_longtext.php @@ -1,4 +1,3 @@ - 'Training', 'EN_text' => 'Workout']); - $text->save(); - $agendaItemCategory = new \App\AgendaItemCategorie(['name' => $text->id]); + $agendaItemCategory = new \App\AgendaItemCategory(['name' => 'Training']); $agendaItemCategory->save(); - $text = new \App\Text(['NL_text' => 'Klimmen', 'EN_text' => 'Climbing']); - $text->save(); - $agendaItemCategory = new \App\AgendaItemCategorie(['name' => $text->id]); + $agendaItemCategory = new \App\AgendaItemCategory(['name' => 'Climbing']); $agendaItemCategory->save(); - $text = new \App\Text(['NL_text' => 'Overige activiteiten', 'EN_text' => 'Other activities']); - $text->save(); - $agendaItemCategory = new \App\AgendaItemCategorie(['name' => $text->id]); + $agendaItemCategory = new \App\AgendaItemCategory(['name' => 'Other activities']); $agendaItemCategory->save(); } } diff --git a/database/seeders/AgendaItemSeeder.php b/database/seeders/AgendaItemSeeder.php index a305d3e4..9c089488 100644 --- a/database/seeders/AgendaItemSeeder.php +++ b/database/seeders/AgendaItemSeeder.php @@ -14,220 +14,143 @@ class AgendaItemSeeder extends Seeder */ public function run() { - $title = new \App\Text(['NL_text' => 'Klimmen Neoliet Zuid', 'EN_text' => 'climbing Neoliet South']); - $title->save(); - $text = new \App\Text(['NL_text' => 'Klimmen bij Neoliet Zuid text', 'EN_text' => 'climbing at Neoliet South text']); - $text->save(); - $shortDescription = new \App\Text(['NL_text' => 'Klimmen bij Neoliet Zuid', 'EN_text' => 'climbing at Neoliet South']); - $shortDescription->save(); - $agendaItem = new \App\AgendaItem(); $agendaItem->startDate = Carbon::now()->addDays(5)->addHours(12); $agendaItem->endDate = Carbon::now()->addDays(5)->addHours(15); $agendaItem->subscription_endDate = Carbon::now()->addDays(2)->addHours(15); - $agendaItem->title = $title->id; - $agendaItem->text = $text->id; - $agendaItem->shortDescription = $shortDescription->id; + $agendaItem->title = 'Climbing Neoliet South'; + $agendaItem->text = 'Climbing at Neoliet South text'; + $agendaItem->shortDescription = 'Climbing at Neoliet South'; $agendaItem->image_url = ""; $agendaItem->createdBy = 1; $agendaItem->category = 2; $agendaItem->application_form_id = 1; $agendaItem->save(); - $title = new \App\Text(['NL_text' => 'Klimmen Neoliet Noord', 'EN_text' => 'climbing Neoliet North']); - $title->save(); - $text = new \App\Text(['NL_text' => 'Klimmen bij Neoliet Noord', 'EN_text' => 'climbing at Neoliet North']); - $text->save(); - $shortDescription = new \App\Text(['NL_text' => 'Klimmen bij Neoliet Noord', 'EN_text' => 'climbing at Neoliet North']); - $shortDescription->save(); - $agendaItem = new \App\AgendaItem(); $agendaItem->startDate = Carbon::now()->addDays(12)->addHours(12); $agendaItem->endDate = Carbon::now()->addDays(12)->addHours(15); $agendaItem->subscription_endDate = Carbon::now()->addDays(2)->addHours(15); - $agendaItem->title = $title->id; - $agendaItem->text = $text->id; - $agendaItem->shortDescription = $shortDescription->id; + $agendaItem->title = 'Climbing Neoliet North'; + $agendaItem->text = 'Climbing at Neoliet North text'; + $agendaItem->shortDescription = 'Climbing at Neoliet North'; $agendaItem->image_url = ""; $agendaItem->createdBy = 1; $agendaItem->category = 1; $agendaItem->application_form_id = 2; $agendaItem->save(); - $title = new \App\Text(['NL_text' => 'Klimmen Neoliet Noord', 'EN_text' => 'climbing Neoliet North']); - $title->save(); - $text = new \App\Text(['NL_text' => 'Klimmen bij Neoliet Noord', 'EN_text' => 'climbing at Neoliet North']); - $text->save(); - $shortDescription = new \App\Text(['NL_text' => 'Klimmen bij Neoliet Noord', 'EN_text' => 'climbing at Neoliet North']); - $shortDescription->save(); - $agendaItem = new \App\AgendaItem(); $agendaItem->startDate = Carbon::now()->addDays(7)->addHours(12); $agendaItem->endDate = Carbon::now()->addDays(7)->addHours(15); $agendaItem->subscription_endDate = Carbon::now()->addDays(2)->addHours(15); - $agendaItem->title = $title->id; - $agendaItem->text = $text->id; - $agendaItem->shortDescription = $shortDescription->id; + $agendaItem->title = 'Climbing Neoliet North'; + $agendaItem->text = 'Climbing at Neoliet North text'; + $agendaItem->shortDescription = 'Climbing at Neoliet North'; $agendaItem->image_url = ""; $agendaItem->createdBy = 1; $agendaItem->category = 1; $agendaItem->application_form_id = 2; - $agendaItem->save();$title = new \App\Text(['NL_text' => 'Klimmen Neoliet Noord', 'EN_text' => 'climbing Neoliet North']); - - $title = new \App\Text(['NL_text' => 'Klimmen Neoliet Noord', 'EN_text' => 'climbing Neoliet North']); - $title->save(); - $text = new \App\Text(['NL_text' => 'Klimmen bij Neoliet Noord', 'EN_text' => 'climbing at Neoliet North']); - $text->save(); - $shortDescription = new \App\Text(['NL_text' => 'Klimmen bij Neoliet Noord', 'EN_text' => 'climbing at Neoliet North']); - $shortDescription->save(); + $agendaItem->save(); $agendaItem = new \App\AgendaItem(); $agendaItem->startDate = Carbon::now()->addDays(14)->addHours(12); $agendaItem->endDate = Carbon::now()->addDays(14)->addHours(15); $agendaItem->subscription_endDate = Carbon::now()->addDays(2)->addHours(15); - $agendaItem->title = $title->id; - $agendaItem->text = $text->id; - $agendaItem->shortDescription = $shortDescription->id; + $agendaItem->title = 'Climbing Neoliet North'; + $agendaItem->text = 'Climbing at Neoliet North text'; + $agendaItem->shortDescription = 'Climbing at Neoliet North'; $agendaItem->image_url = ""; $agendaItem->createdBy = 1; $agendaItem->category = 1; $agendaItem->application_form_id = 2; - $agendaItem->save();$title = new \App\Text(['NL_text' => 'Klimmen Neoliet Noord', 'EN_text' => 'climbing Neoliet North']); - - $title = new \App\Text(['NL_text' => 'Klimmen Neoliet Noord', 'EN_text' => 'climbing Neoliet North']); - $title->save(); - $text = new \App\Text(['NL_text' => 'Klimmen bij Neoliet Noord', 'EN_text' => 'climbing at Neoliet North']); - $text->save(); - $shortDescription = new \App\Text(['NL_text' => 'Klimmen bij Neoliet Noord', 'EN_text' => 'climbing at Neoliet North']); - $shortDescription->save(); + $agendaItem->save(); $agendaItem = new \App\AgendaItem(); $agendaItem->startDate = Carbon::now()->addDays(21)->addHours(12); $agendaItem->endDate = Carbon::now()->addDays(21)->addHours(15); $agendaItem->subscription_endDate = Carbon::now()->addDays(2)->addHours(15); - $agendaItem->title = $title->id; - $agendaItem->text = $text->id; - $agendaItem->shortDescription = $shortDescription->id; + $agendaItem->title = 'Climbing Neoliet North'; + $agendaItem->text = 'Climbing at Neoliet North text'; + $agendaItem->shortDescription = 'Climbing at Neoliet North'; $agendaItem->image_url = ""; $agendaItem->createdBy = 1; $agendaItem->category = 1; $agendaItem->application_form_id = 2; $agendaItem->save(); - $title = new \App\Text(['NL_text' => 'Klimmen Neoliet Noord', 'EN_text' => 'climbing Neoliet North']); - $title->save(); - $text = new \App\Text(['NL_text' => 'Klimmen bij Neoliet Noord', 'EN_text' => 'climbing at Neoliet North']); - $text->save(); - $shortDescription = new \App\Text(['NL_text' => 'Klimmen bij Neoliet Noord', 'EN_text' => 'climbing at Neoliet North']); - $shortDescription->save(); - $agendaItem = new \App\AgendaItem(); $agendaItem->startDate = Carbon::now()->addDays(21)->addHours(12); $agendaItem->endDate = Carbon::now()->addDays(21)->addHours(15); $agendaItem->subscription_endDate = Carbon::now()->addDays(2)->addHours(15); - $agendaItem->title = $title->id; - $agendaItem->text = $text->id; - $agendaItem->shortDescription = $shortDescription->id; + $agendaItem->title = 'Climbing Neoliet North'; + $agendaItem->text = 'Climbing at Neoliet North text'; + $agendaItem->shortDescription = 'Climbing at Neoliet North'; $agendaItem->image_url = ""; $agendaItem->createdBy = 1; $agendaItem->category = 1; $agendaItem->application_form_id = 2; - $agendaItem->save();$title = new \App\Text(['NL_text' => 'Klimmen Neoliet Noord', 'EN_text' => 'climbing Neoliet North']); - - $title = new \App\Text(['NL_text' => 'Klimmen Neoliet Noord', 'EN_text' => 'climbing Neoliet North']); - $title->save(); - $text = new \App\Text(['NL_text' => 'Klimmen bij Neoliet Noord', 'EN_text' => 'climbing at Neoliet North']); - $text->save(); - $shortDescription = new \App\Text(['NL_text' => 'Klimmen bij Neoliet Noord', 'EN_text' => 'climbing at Neoliet North']); - $shortDescription->save(); + $agendaItem->save(); $agendaItem = new \App\AgendaItem(); $agendaItem->startDate = Carbon::now()->addDays(28)->addHours(12); $agendaItem->endDate = Carbon::now()->addDays(28)->addHours(15); $agendaItem->subscription_endDate = Carbon::now()->addDays(2)->addHours(15); - $agendaItem->title = $title->id; - $agendaItem->text = $text->id; - $agendaItem->shortDescription = $shortDescription->id; + $agendaItem->title = 'Climbing Neoliet North'; + $agendaItem->text = 'Climbing at Neoliet North text'; + $agendaItem->shortDescription = 'Climbing at Neoliet North'; $agendaItem->image_url = ""; $agendaItem->createdBy = 1; $agendaItem->category = 1; $agendaItem->application_form_id = 2; - $agendaItem->save();$title = new \App\Text(['NL_text' => 'Klimmen Neoliet Noord', 'EN_text' => 'climbing Neoliet North']); - - $title = new \App\Text(['NL_text' => 'Klimmen Neoliet Noord', 'EN_text' => 'climbing Neoliet North']); - $title->save(); - $text = new \App\Text(['NL_text' => 'Klimmen bij Neoliet Noord', 'EN_text' => 'climbing at Neoliet North']); - $text->save(); - $shortDescription = new \App\Text(['NL_text' => 'Klimmen bij Neoliet Noord', 'EN_text' => 'climbing at Neoliet North']); - $shortDescription->save(); + $agendaItem->save(); $agendaItem = new \App\AgendaItem(); $agendaItem->startDate = Carbon::now()->addDays(35)->addHours(12); $agendaItem->endDate = Carbon::now()->addDays(35)->addHours(15); $agendaItem->subscription_endDate = Carbon::now()->addDays(2)->addHours(15); - $agendaItem->title = $title->id; - $agendaItem->text = $text->id; - $agendaItem->shortDescription = $shortDescription->id; + $agendaItem->title = 'Climbing Neoliet North'; + $agendaItem->text = 'Climbing at Neoliet North text'; + $agendaItem->shortDescription = 'Climbing at Neoliet North'; $agendaItem->image_url = ""; $agendaItem->createdBy = 1; $agendaItem->category = 1; $agendaItem->application_form_id = 2; $agendaItem->save(); - $title = new \App\Text(['NL_text' => 'Klimmen Neoliet Noord', 'EN_text' => 'climbing Neoliet North']); - $title->save(); - $text = new \App\Text(['NL_text' => 'Klimmen bij Neoliet Noord', 'EN_text' => 'climbing at Neoliet North']); - $text->save(); - $shortDescription = new \App\Text(['NL_text' => 'Klimmen bij Neoliet Noord', 'EN_text' => 'climbing at Neoliet North']); - $shortDescription->save(); - $agendaItem = new \App\AgendaItem(); $agendaItem->startDate = Carbon::now()->addDays(42)->addHours(12); $agendaItem->endDate = Carbon::now()->addDays(42)->addHours(15); $agendaItem->subscription_endDate = Carbon::now()->addDays(2)->addHours(15); - $agendaItem->title = $title->id; - $agendaItem->text = $text->id; - $agendaItem->shortDescription = $shortDescription->id; + $agendaItem->title = 'Climbing Neoliet North'; + $agendaItem->text = 'Climbing at Neoliet North text'; + $agendaItem->shortDescription = 'Climbing at Neoliet North'; $agendaItem->image_url = ""; $agendaItem->createdBy = 1; $agendaItem->category = 1; $agendaItem->application_form_id = 2; $agendaItem->save(); - $title = new \App\Text(['NL_text' => 'Klimmen Neoliet Noord', 'EN_text' => 'climbing Neoliet North']); - $title->save(); - $text = new \App\Text(['NL_text' => 'Klimmen bij Neoliet Noord', 'EN_text' => 'climbing at Neoliet North']); - $text->save(); - $shortDescription = new \App\Text(['NL_text' => 'Klimmen bij Neoliet Noord', 'EN_text' => 'climbing at Neoliet North']); - $shortDescription->save(); - $agendaItem = new \App\AgendaItem(); $agendaItem->startDate = Carbon::now()->addDays(49)->addHours(12); $agendaItem->endDate = Carbon::now()->addDays(49)->addHours(15); $agendaItem->subscription_endDate = Carbon::now()->addDays(2)->addHours(15); - $agendaItem->title = $title->id; - $agendaItem->text = $text->id; - $agendaItem->shortDescription = $shortDescription->id; + $agendaItem->title = 'Climbing Neoliet North'; + $agendaItem->text = 'Climbing at Neoliet North text'; + $agendaItem->shortDescription = 'Climbing at Neoliet North'; $agendaItem->image_url = ""; $agendaItem->createdBy = 1; $agendaItem->category = 1; $agendaItem->application_form_id = 2; $agendaItem->save(); - $title = new \App\Text(['NL_text' => 'Klimmen Neoliet Noord', 'EN_text' => 'climbing Neoliet North']); - $title->save(); - $text = new \App\Text(['NL_text' => 'Klimmen bij Neoliet Noord', 'EN_text' => 'climbing at Neoliet North']); - $text->save(); - $shortDescription = new \App\Text(['NL_text' => 'Klimmen bij Neoliet Noord', 'EN_text' => 'climbing at Neoliet North']); - $shortDescription->save(); - $agendaItem = new \App\AgendaItem(); $agendaItem->startDate = Carbon::now()->addDays(56)->addHours(12); $agendaItem->endDate = Carbon::now()->addDays(56)->addHours(15); $agendaItem->subscription_endDate = Carbon::now()->addDays(2)->addHours(15); - $agendaItem->title = $title->id; - $agendaItem->text = $text->id; - $agendaItem->shortDescription = $shortDescription->id; + $agendaItem->title = 'Climbing Neoliet North'; + $agendaItem->text = 'Climbing at Neoliet North text'; + $agendaItem->shortDescription = 'Climbing at Neoliet North'; $agendaItem->image_url = ""; $agendaItem->createdBy = 1; $agendaItem->category = 1; diff --git a/database/seeders/ApplicationFormSeeder.php b/database/seeders/ApplicationFormSeeder.php index 3904cd96..1badbf27 100644 --- a/database/seeders/ApplicationFormSeeder.php +++ b/database/seeders/ApplicationFormSeeder.php @@ -4,7 +4,6 @@ use App\Models\ApplicationForm\ApplicationForm; use App\Models\ApplicationForm\ApplicationFormRow; -use App\Text; use Illuminate\Database\Seeder; class ApplicationFormSeeder extends Seeder @@ -16,51 +15,37 @@ class ApplicationFormSeeder extends Seeder */ public function run() { - $text = new Text(['NL_text' => 'Inschrijf formulier klim weekend ', 'EN_text' => 'Aplication form climbing weekend']); - $text->save(); - - $applicationForm = new ApplicationForm(['name' => $text->id]); + $applicationForm = new ApplicationForm(); + $applicationForm->name = 'Aplication form climbing weekend'; $applicationForm->save(); - $text = new Text(['NL_text' => 'Auto beschikbaar', 'EN_text' => 'Car available']); - $text->save(); $row = new ApplicationFormRow(); - $row->name = $text->id; + $row->name = 'Car available'; $row->type = "Checkbox"; $row->required = 1; $row->application_form_id = $applicationForm->id; $row->save(); - - $text = new Text(['NL_text' => 'Tent beschikbaar', 'EN_text' => 'Tent available']); - $text->save(); $row = new ApplicationFormRow(); - $row->name = $text->id; - $row->type = "Cijfer"; + $row->name = 'Tent available'; + $row->type = "Number"; $row->required = 1; $row->application_form_id = $applicationForm->id; $row->save(); - $text = new Text(['NL_text' => 'Eet wensen', 'EN_text' => 'Food reqeusts']); - $text->save(); $row = new ApplicationFormRow(); - $row->name = $text->id; + $row->name = 'Food reqeusts'; $row->type = "Text"; $row->required = 0; $row->application_form_id = $applicationForm->id; $row->save(); //second application form - $text = new Text(['NL_text' => 'Inschrijf formulier activiteit', 'EN_text' => 'Aplication form activitie']); - $text->save(); - - $applicationForm = new ApplicationForm(['name' => $text->id]); + $applicationForm = new ApplicationForm(); + $applicationForm->name = 'Aplication form activity'; $applicationForm->save(); - - $text = new Text(['NL_text' => 'Eet wensen', 'EN_text' => 'Food reqeusts']); - $text->save(); $row = new ApplicationFormRow(); - $row->name = $text->id; + $row->name = 'Food reqeusts'; $row->type = "Text"; $row->required = 0; $row->application_form_id = $applicationForm->id; diff --git a/database/seeders/ApplicationResponseSeeder.php b/database/seeders/ApplicationResponseSeeder.php index ea4e5da3..6c156f6b 100644 --- a/database/seeders/ApplicationResponseSeeder.php +++ b/database/seeders/ApplicationResponseSeeder.php @@ -16,7 +16,7 @@ public function run() { $applicationResponse = new ApplicationResponse(); - $applicationResponse->agenda_id=1; + $applicationResponse->agenda_id = 1; $applicationResponse->inschrijf_form_id = 1; $applicationResponse->user_id = 1; $applicationResponse->save(); diff --git a/database/seeders/BooksTableSeeder.php b/database/seeders/BooksTableSeeder.php index 34af1aa7..2067208e 100644 --- a/database/seeders/BooksTableSeeder.php +++ b/database/seeders/BooksTableSeeder.php @@ -2,6 +2,7 @@ namespace Database\Seeders; +use App\Book; use Illuminate\Database\Seeder; class BooksTableSeeder extends Seeder @@ -13,7 +14,7 @@ class BooksTableSeeder extends Seeder */ public function run() { - $book = new \App\Book(); + $book = new Book(); $book->title = "Dit is een boek"; $book->year = 2012; $book->country = "Nederland"; diff --git a/database/seeders/CertificaatSeeder.php b/database/seeders/CertificaatSeeder.php index cb411bab..9d8c3802 100644 --- a/database/seeders/CertificaatSeeder.php +++ b/database/seeders/CertificaatSeeder.php @@ -2,6 +2,7 @@ namespace Database\Seeders; +use App\Certificate; use Illuminate\Database\Seeder; class CertificaatSeeder extends Seeder @@ -13,14 +14,10 @@ class CertificaatSeeder extends Seeder */ public function run() { - $text = new \App\Text(['NL_text' => 'Outdoor voorklimmen', 'EN_text' => 'Outdoor lead climbing ']); - $text->save(); - $certificat = new \App\certificate(['name' => $text->id, 'abbreviation' => "OV"]); + $certificat = new Certificate(['name' => 'Outdoor lead climbing', 'abbreviation' => "OV"]); $certificat->save(); - $text = new \App\Text(['NL_text' => 'Indoor voorklimmen', 'EN_text' => 'Indoor lead climbing ']); - $text->save(); - $certificat = new \App\certificate(['name' => $text->id, 'abbreviation' => "IV"]); + $certificat = new Certificate(['name' => 'Indoor lead climbing', 'abbreviation' => "IV"]); $certificat->save(); } } diff --git a/database/seeders/ClearSeeder.php b/database/seeders/ClearSeeder.php index d7c2f40e..e2cb7f42 100644 --- a/database/seeders/ClearSeeder.php +++ b/database/seeders/ClearSeeder.php @@ -3,7 +3,8 @@ namespace Database\Seeders; use App\AgendaItem; -use App\AgendaItemCategorie; +use App\AgendaItemCategory; +use App\Book; use App\Certificate; use App\MenuItem; use App\Models\ApplicationForm\ApplicationForm; @@ -15,7 +16,6 @@ use App\Zekering; use Illuminate\Database\Seeder; - //emptys data from database class ClearSeeder extends Seeder { @@ -26,17 +26,17 @@ class ClearSeeder extends Seeder */ public function run() { + Zekering::getQuery()->delete(); Certificate::getQuery()->delete(); MenuItem::getQuery()->delete(); - Rol::getQuery()->delete(); AgendaItem::getQuery()->delete(); - AgendaItemCategorie::getQuery()->delete(); + AgendaItemCategory::getQuery()->delete(); ApplicationFormRow::getQuery()->delete(); - ApplicationForm::getQuery()->delete(); NewsItem::getQuery()->delete(); - User::getQuery()->delete(); Text::getQuery()->delete(); - Zekering::getQuery()->delete(); - \App\Book::getQuery()->delete(); + Book::getQuery()->delete(); + ApplicationForm::getQuery()->delete(); + User::getQuery()->delete(); + Rol::getQuery()->delete(); } } diff --git a/database/seeders/MenuItemTableSeeder.php b/database/seeders/MenuItemTableSeeder.php index a0a2925b..294fb1ab 100644 --- a/database/seeders/MenuItemTableSeeder.php +++ b/database/seeders/MenuItemTableSeeder.php @@ -15,116 +15,84 @@ public function run() { //homepage - $text = new \App\Text(['NL_text' => 'Home', 'EN_text' => 'Home']); - $text->save(); - $content = new \App\Text(['NL_text' => '
Welkom bij de ESAC, dé studenten klim- en bergsportvereniging van Eindhoven. Op onze website vind je meer informatie over wat de ESAC te bieden heeft. Heb je vragen? Neem dan vooral contact op met het bestuur.
-De Eindhovense Studenten Alpen Club houdt zich in de breedste zin bezig met de bergsport. Met veel plezier en gezelligheid genieten we van de hoogteverschillen in het landschap of in de hal. Hieronder is actuele informatie te vinden, informatie over lid worden of contact opnemen zijn elders op de website te vinden.
', - 'EN_text' => 'Welkom bij de ESAC, dé studenten klim- en bergsportvereniging van Eindhoven. Op onze website vind je meer informatie over wat de ESAC te bieden heeft. Heb je vragen? Neem dan vooral contact op met het bestuur.
- -De Eindhovense Studenten Alpen Club houdt zich in de breedste zin bezig met de bergsport. Met veel plezier en gezelligheid genieten we van de hoogteverschillen in het landschap of in de hal. Hieronder is actuele informatie te vinden, informatie over lid worden of contact opnemen zijn elders op de website te vinden.
- ', ]); - $content->save(); +De Eindhovense Studenten Alpen Club houdt zich in de breedste zin bezig met de bergsport. Met veel plezier en gezelligheid genieten we van de hoogteverschillen in het landschap of in de hal. Hieronder is actuele informatie te vinden, informatie over lid worden of contact opnemen zijn elders op de website te vinden.
'; $menuItem = new \App\MenuItem(); - $menuItem->name = $text->id; + $menuItem->name = 'Home'; $menuItem->urlName = \App\MenuItem::HOMEURL; $menuItem->login = false; $menuItem->deletable = false; $menuItem->editable = true; $menuItem->menuItem = true; - $menuItem->content_id = $content->id; + $menuItem->content = $content; $menuItem->save(); //agenda - $text = new \App\Text(['NL_text' => 'Agenda', 'EN_text' => 'Agenda']); - $text->save(); - $content = new \App\Text(['NL_text' => 'Agenda content', 'EN_text' => 'Agenda content']); - $content->save(); $menuItem = new \App\MenuItem(); - $menuItem->name = $text->id; + $menuItem->name = 'Agenda'; $menuItem->urlName = \App\MenuItem::AGENDAURL; $menuItem->login = false; $menuItem->deletable = false; $menuItem->editable = true; $menuItem->menuItem = true; - $menuItem->content_id = $content->id; + $menuItem->content = 'Agenda content'; $menuItem->save(); //memberlist - $text = new \App\Text(['NL_text' => 'Ledenlijst', 'EN_text' => 'Members list']); - $text->save(); - $content = new \App\Text(['NL_text' => 'Ledenlijst content', 'EN_text' => 'Members list content']); - $content->save(); $menuItem = new \App\MenuItem(); - $menuItem->name = $text->id; + $menuItem->name = 'Members list'; $menuItem->urlName = \App\MenuItem::MEMBERLISTURL; $menuItem->login = true; $menuItem->deletable = false; $menuItem->editable = true; $menuItem->menuItem = true; - $menuItem->content_id = $content->id; + $menuItem->content = 'Members list content'; $menuItem->save(); //news - $text = new \App\Text(['NL_text' => 'Nieuws', 'EN_text' => 'News']); - $text->save(); - $content = new \App\Text(['NL_text' => 'Nieuws content', 'EN_text' => 'News content']); - $content->save(); $menuItem = new \App\MenuItem(); - $menuItem->name = $text->id; + $menuItem->name = 'News'; $menuItem->urlName = \App\MenuItem::NEWSURL; $menuItem->login = false; $menuItem->deletable = false; $menuItem->editable = true; $menuItem->menuItem = true; - $menuItem->content_id = $content->id; + $menuItem->content = 'News content'; $menuItem->save(); //subscribe - $text = new \App\Text(['NL_text' => 'Meld je aan als lid', 'EN_text' => 'Subscribe as member']); - $text->save(); - $content = new \App\Text(['NL_text' => 'Aanmelden content', 'EN_text' => 'Subscribe content']); - $content->save(); $menuItem = new \App\MenuItem(); - $menuItem->name = $text->id; + $menuItem->name = 'Subscribe as member'; $menuItem->urlName = \App\MenuItem::SUBSCRIBEURL; $menuItem->login = false; $menuItem->deletable = false; $menuItem->editable = true; $menuItem->menuItem = true; - $menuItem->content_id = $content->id; + $menuItem->content = 'Subscribe content'; $menuItem->save(); //library - $text = new \App\Text(['NL_text' => 'Bibliotheek', 'EN_text' => 'Library']); - $text->save(); - $content = new \App\Text(['NL_text' => 'Bibliotheek content', 'EN_text' => 'Library content']); - $content->save(); $menuItem = new \App\MenuItem(); - $menuItem->name = $text->id; + $menuItem->name = 'Library'; $menuItem->urlName = \App\MenuItem::LIBRARYURL; $menuItem->login = false; $menuItem->deletable = false; $menuItem->editable = true; $menuItem->menuItem = true; - $menuItem->content_id = $content->id; + $menuItem->content = 'Library content'; $menuItem->save(); //zekeringen page page - $text = new \App\Text(['NL_text' => 'Zekeringen', 'EN_text' => 'Zekeringen']); - $text->save(); - $content = new \App\Text(['NL_text' => 'Zekeringen content', 'EN_text' => 'Zekeringen content']); - $content->save(); $menuItem = new \App\MenuItem(); - $menuItem->name = $text->id; + $menuItem->name = 'Zekeringen'; $menuItem->urlName = \App\MenuItem::ZEKERINGURL; $menuItem->login = true; $menuItem->editable = true; $menuItem->deletable = false; $menuItem->menuItem = true; - $menuItem->content_id = $content->id; + $menuItem->content = 'Zekeringen content'; $menuItem->save(); } } diff --git a/database/seeders/NewsItemSeeder.php b/database/seeders/NewsItemSeeder.php index 95a489b3..7e139d01 100644 --- a/database/seeders/NewsItemSeeder.php +++ b/database/seeders/NewsItemSeeder.php @@ -13,25 +13,15 @@ class NewsItemSeeder extends Seeder */ public function run() { - $title = new \App\Text(['NL_text' => 'Nieuwe website!', 'EN_text' => 'New website esac!']); - $title->save(); - $text = new \App\Text(['NL_text' => 'Sommigen van jullie hebben misschien al geruchten gehoord, maar het is echt waar: in 2017 komt er een gloednieuwe ESAC-website. Allereerst veel dank voor de internetcommissie, die hard bezig is om dit mogelijk te maken! Iedereen die graag updates over de nieuwe website wil ontvangen, kan zich via een e-mail naar de IC aanmelden voor de maillijst. Als je nog goede ideeën hebt, vertel deze dan snel aan de IC; hoe verder het ontwikkelingsproces gevorderd is, hoe lastiger het wordt om nieuwe ideeën te implementeren.', 'EN_text' => 'Some of you may have heard rumors, but it is true: in 2017, there will be a brand new ESAC website. First of all, thank you for the internet commission, who is working hard to make this happen! Anyone who would like to receive updates about the new website can log in to the IC by email to the IC. If you have any good ideas, please tell them the IC quickly; The further the development process is advanced, the more difficult it becomes to implement new ideas.']); - $text->save(); - $newsItem = new \App\NewsItem(); - $newsItem->title = $title->id; - $newsItem->text = $text->id; + $newsItem->title = 'New website esac!'; + $newsItem->text = 'Some of you may have heard rumors, but it is true: in 2017, there will be a brand new ESAC website. First of all, thank you for the internet commission, who is working hard to make this happen! Anyone who would like to receive updates about the new website can log in to the IC by email to the IC. If you have any good ideas, please tell them the IC quickly; The further the development process is advanced, the more difficult it becomes to implement new ideas.'; $newsItem->author = "Piet jansen"; $newsItem->save(); - $title = new \App\Text(['NL_text' => 'Korting monk!', 'EN_text' => 'Discount Monk!']); - $title->save(); - $text = new \App\Text(['NL_text' => 'Goed nieuws! Vanaf 1 mei kunnen alle ESAC-leden op zondagavond op Monk klokken op 6.00 euro. De korting begint vanaf 18:00 op zondag en is van toepassing op iedereen, dus zelfs als u geen sportkaart hebt, krijgt u korting.Op dit moment is het gebaseerd op goed vertrouwen, als je Monk weet dat je een ESAC lid bent, krijg je de korting. Als de korting succesvol lijkt te zijn, zullen we iets anders opleveren om ESAC-leden bij Monk te identificeren.', 'EN_text' => 'Good news! From May the 1st onward, all ESAC members can boulder at Monk on Sunday evening for 6.50 euros. The discount starts from 18:00 on Sundays and applies to everyone, so even if you do not have a sports card you get a discount. At the moment, it is based on good faith, if you let Monk know that you are an ESAC member, you get the discount. If the discount appears to be successful, we will come up with something else to identify ESAC members at Monk.']); - $text->save(); - $newsItem = new \App\NewsItem(); - $newsItem->title = $title->id; - $newsItem->text = $text->id; + $newsItem->title = 'Discount Monk!'; + $newsItem->text = 'Good news! From May the 1st onward, all ESAC members can boulder at Monk on Sunday evening for 6.50 euros. The discount starts from 18:00 on Sundays and applies to everyone, so even if you do not have a sports card you get a discount. At the moment, it is based on good faith, if you let Monk know that you are an ESAC member, you get the discount. If the discount appears to be successful, we will come up with something else to identify ESAC members at Monk.'; $newsItem->author = "Klaas jansen"; $newsItem->save(); } diff --git a/database/seeders/RolTableSeeder.php b/database/seeders/RolTableSeeder.php index 5d2f4c27..602dec9f 100644 --- a/database/seeders/RolTableSeeder.php +++ b/database/seeders/RolTableSeeder.php @@ -14,21 +14,13 @@ class RolTableSeeder extends Seeder public function run() { //add default data - $text = new \App\Text(['NL_text' => 'Beheerder', 'EN_text' => 'Administrator']); - $text->save(); - $rol = new \App\Rol(['name' => $text->id]); + $rol = new \App\Rol(['name' => 'Administrator']); $rol->save(); - $text = new \App\Text(['NL_text' => 'Content beheerder', 'EN_text' => 'Content administrator']); - $text->save(); - $rol = new \App\Rol(['name' => $text->id]); + $rol = new \App\Rol(['name' => 'Content administrator']); $rol->save(); - $text = new \App\Text(['NL_text' => 'Activiteit beheerder', 'EN_text' => 'Activity administrator']); - $text->save(); - $rol = new \App\Rol(['name' => $text->id]); + $rol = new \App\Rol(['name' => 'Activity administrator']); $rol->save(); - $text = new \App\Text(['NL_text' => 'Certificaat beheerder', 'EN_text' => 'Certificate administrator']); - $text->save(); - $rol = new \App\Rol(['name' => $text->id]); + $rol = new \App\Rol(['name' => 'Certificate administrator']); $rol->save(); } -} \ No newline at end of file +} diff --git a/database/seeders/UsersTableSeeder.php b/database/seeders/UsersTableSeeder.php index f5a16ee4..22d50923 100644 --- a/database/seeders/UsersTableSeeder.php +++ b/database/seeders/UsersTableSeeder.php @@ -34,7 +34,7 @@ public function run() $user->emergencycity = "Eindhoven"; $user->emergencyzipcode = "3633IK"; $user->emergencycountry = "NL"; - $user->birthDay = Carbon::now()->subYear(20); + $user->birthDay = Carbon::now()->subYears(20); $user->kind_of_member = "member"; $user->IBAN = "NL55 RABO 0107331020"; $user->BIC = ""; @@ -66,7 +66,7 @@ public function run() $user->emergencycity = "Eindhoven"; $user->emergencyzipcode = "3633IK"; $user->emergencycountry = "NL"; - $user->birthDay = Carbon::now()->subYear(20); + $user->birthDay = Carbon::now()->subYears(20); $user->kind_of_member = "member"; $user->IBAN = "NL55 RABO 0107331020"; $user->BIC = ""; @@ -94,7 +94,7 @@ public function run() $user->emergencycity = "Eindhoven"; $user->emergencyzipcode = "3633IK"; $user->emergencycountry = "NL"; - $user->birthDay = Carbon::now()->subYear(20); + $user->birthDay = Carbon::now()->subYears(20); $user->kind_of_member = "member"; $user->IBAN = "NL55 RABO 0107331020"; $user->BIC = ""; diff --git a/phpunit.xml b/phpunit.xml index 5e6e9a06..75d371da 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -20,6 +20,5 @@{{trans('AgendaItems.title')}} | -{{$agendaItem->agendaItemTitle->text()}} | +{{'Title'}} | +{{$agendaItem->title}} |
{{trans('AgendaItems.shortDescription')}} | -{{$agendaItem->agendaItemShortDescription->text()}} | +{{'Short description'}} | +{{$agendaItem->shortDescription}} |
{{trans('AgendaItems.startDate')}} | +{{'Start date'}} | {{\Carbon\Carbon::parse($agendaItem->startDate)->format('d-m-Y h:i')}} | |
{{trans('AgendaItems.endDate')}} | +{{'End date'}} | {{\Carbon\Carbon::parse($agendaItem->endDate)->format('d-m-Y h:i')}} | |
{{trans('AgendaItems.endDateSubscription')}} | +{{'Last possible registration date'}} | {{($agendaItem->subscription_endDate !=null)? \Carbon\Carbon::parse($agendaItem->subscription_endDate)->format('d-m-Y h:i') : ""}} | |
{{trans('AgendaItems.category')}} | -{{$agendaItem->agendaItemCategory->categorieName->text()}} | +{{'Category'}} | +{{$agendaItem->agendaItemCategory->name}} |
{{trans('AgendaItems.climbingActivity')}} | -{{$agendaItem->climbing_activity ? trans('menu.yes') : trans('menu.no')}} | +{{'Show certificates in the event item'}} | +{{$agendaItem->climbing_activity ? 'Yes' : 'No'}} |
{{trans('AgendaItems.createdBy')}} | +{{'Created by'}} | {{$agendaItem->getCreatedBy->getName()}} | |
{{trans("AgendaItems.applicationForm")}} | -{{($agendaItem->application_form_id !=null)? $agendaItem->getApplicationForm->applicationFormName->text():""}} | +{{'Application form'}} | +{{($agendaItem->application_form_id !=null)? $agendaItem->getApplicationForm->name:""}} |
{{trans("AgendaItems.tumpnailImage")}} | +{{'Thumbnail image'}} |
{{trans('agendaItemCategory.name')}} | +{{'Name'}} | Beheer | |||||
---|---|---|---|---|---|---|---|
{{$category->categorieName->text()}} | +{{$category->name}} | - - + + |
{{trans('ApplicationForm.name')}} - | {{trans('ApplicationForm.rowType')}} - | {{trans('ApplicationForm.rowRequired')}} - | {{trans('ApplicationForm.rowOptions')}} + | {{'Name'}} + | {{'Row type'}} + | {{'Value required'}} + | {{'Options'}} | @foreach($applicationForm->applicationFormRows as $row)
---|---|---|---|---|---|
{{$row->applicationFormRowName->text()}} | +{{$row->name}} | {{$row->type}} | -{{($row->required == 1)? trans('menu.yes'): trans('menu.no')}} | +{{($row->required == 1)? 'Yes': 'No'}} |
@if ($row->applicationFormRowOptions->count() > 0)
|
{{trans('book.title')}} | +{{'Title'}} | {{ $book->title }} |
{{trans('book.year')}} | +{{'Year'}} | {{ $book->year }} |
{{trans('book.country')}} | +{{'Country'}} | {{ $book->country }} |
{{trans('book.type')}} | +{{'Type'}} | {{ $book->type }} |
{{trans('book.code')}} | +{{'Code'}} | {{ $book->code }} |
- {{trans('certificate.name')}} + {{'Name'}} | - {{$certificate->certificateName->text()}} + {{$certificate->name}} |
- {{trans('certificate.abbreviation')}} + {{'Abbreviation'}} | {{$certificate->abbreviation}} |
- {{trans('certificate.duration')}} - | -- {{$certificate->duration === 0 ? "" : $certificate->duration}} - | -
- {{trans('MailList.name')}} + {{'Name'}} | {{$mailList->getName()}} @@ -40,7 +40,7 @@ |
- {{trans('MailList.address')}} + {{'Email'}} | {{$mailList->getAddress()}} @@ -48,19 +48,19 @@ |
- {{trans('MailList.members_count')}} + {{'Members count'}} | {{$mailList->getMembersCount()}} |
{{trans('MailList.address')}} | -{{trans('MailList.name')}} | -{{trans('menu.beheer')}} | +{{'Email'}} | +{{'Name'}} | +{{'Management'}} | @foreach($mailList->getMembers() as $member) @@ -88,22 +88,15 @@ @push('scripts') @yield('modal_javascript') -@endpush \ No newline at end of file +@endpush diff --git a/resources/views/beheer/menu/create_edit.blade.php b/resources/views/beheer/menu/create_edit.blade.php index f20c2432..42bd730b 100644 --- a/resources/views/beheer/menu/create_edit.blade.php +++ b/resources/views/beheer/menu/create_edit.blade.php @@ -22,8 +22,8 @@ @endif
{{trans('menuItems.name')}} | -{{trans('menuItems.SubItemVan')}} | -{{trans('menuItems.afterItem')}} | +{{'Name'}} | +{{'Sub item of'}} | +{{'After menu item'}} | Beheer | |
---|---|---|---|---|---|---|---|
{{$menu->text->text()}} | -{{($menu->partner != null) ? $menu->partner->text->text() : ""}} | -{{($menu->after != null) ? $menu->afterItem->text->text() : ""}} | +{{$menu->name}} | +{{($menu->partner != null) ? $menu->partner->name : ""}} | +{{($menu->after != null) ? $menu->afterItem->name : ""}} | - - + + |
{{trans('menuItems.name')}} | -{{$page->text->text() }} | +{{'Name'}} | +{{$page->name}} | |
{{trans('menuItems.SubItemVan')}} | -{{($page->partner != null) ?$page->partner->text->text() : ""}} | +{{'Sub item of'}} | +{{($page->partner != null) ?$page->partner->name : ""}} | |
{{trans('menuItems.urlName')}} | +{{'URL name'}} | {{$page->urlName}} | ||
{{trans('menuItems.needLogin')}} | -{{($page->login)? trans("menu.yes") : trans("menu.no")}} | +{{'User needs to be logged in to view the page'}} | +{{($page->login)? 'Yes' : 'No'}} | |
{{trans('menuItems.afterItem')}} | -{{($page->after != null) ?$page->afterItem->text->text() : ""}} | +{{'After menu item'}} | +{{($page->after != null) ?$page->afterItem->name : ""}} | |
{{trans('menuItems.subItems')}} | - @if( count($subItems) > 0) -- {{$subItems[0]->text->text()}} - | - @else -- @endif + | {{'Submenu items'}} | +{{$subItems[0]->name}} |
- {{$subItems[$i]->text->text()}} - | +{{ $subItems[$i]->name }} |
{{trans('NewsItem.title')}} | -{{trans('NewsItem.createdBy')}} | -{{trans('NewsItem.placeDate')}} | -{{trans('menu.beheer')}} | +{{'Title'}} | +{{'Created by'}} | +{{'Created at'}} | +{{'Management'}} |
---|---|---|---|---|---|---|---|
{{$newsItem->newsItemTitle->text()}} | +{{$newsItem->title}} | {{$newsItem->author}} | {{\Carbon\Carbon::parse($newsItem->created_at)->format('d-m-Y h:i')}} | - - + + |
{{trans('NewsItem.title')}} | -{{$newsItem->newsItemTitle->text()}} | +{{'Title'}} | +{{$newsItem->title}} | ||||
{{trans('NewsItem.placeDate')}} | +{{'Created at'}} | {{\Carbon\Carbon::parse($newsItem->created_at)->format('d-m-Y h:i')}} | |||||
{{trans('NewsItem.createdBy')}} | +{{'Created by'}} | {{$newsItem->author}} | |||||
{{trans("NewsItem.newsImage")}} | +{{'Image'}} |
{{trans('rol.name')}} | -{{trans('menu.beheer')}} | +Name | +Management |
---|---|---|---|
{{$rol->text->text()}} | +{{$rol->name}} | - - + + |
{{ trans('settings.name') }} | -{{ trans('settings.value') }} | +{{ 'Name' }} | +{{ 'Value' }} | @foreach($settings as $setting) diff --git a/resources/views/beheer/user/addCertificate.blade.php b/resources/views/beheer/user/addCertificate.blade.php index f448a83b..49e8192f 100644 --- a/resources/views/beheer/user/addCertificate.blade.php +++ b/resources/views/beheer/user/addCertificate.blade.php @@ -25,25 +25,16 @@
---|
{{trans('user.name')}} | -{{trans('user.email')}} | -{{trans('user.kind_of_member')}} | -{{trans('menu.beheer')}} | +{{'Name'}} | +{{'Email address'}} | +{{'Type of member'}} | +{{'Management'}} | - - + + | @endforeach diff --git a/resources/views/beheer/user/index_pending_users.blade.php b/resources/views/beheer/user/index_pending_users.blade.php index 9223154c..54beabaa 100644 --- a/resources/views/beheer/user/index_pending_users.blade.php +++ b/resources/views/beheer/user/index_pending_users.blade.php @@ -1,7 +1,7 @@ @extends('layouts.beheer') @section('title') -{{trans("user.pending_members")}} +{{'Pending users'}} @endsection @section('content') @@ -16,15 +16,15 @@
---|
{{trans('user.name')}} | -{{trans('user.email')}} | -{{trans('user.kind_of_member')}} | +{{'Name'}} | +{{'Email address'}} | +{{'Type of member'}} | Beheer | {{$user->email}} | {{trans('kind_of_member.' . $user->kind_of_member)}} | - - + + | @endforeach diff --git a/resources/views/beheer/user/show.blade.php b/resources/views/beheer/user/show.blade.php index dbe78757..6e9dcc20 100644 --- a/resources/views/beheer/user/show.blade.php +++ b/resources/views/beheer/user/show.blade.php @@ -1,7 +1,7 @@ @extends('layouts.beheer') @section('title') -{{trans('user.info') . $user->getName()}} +{{'Info of ' . $user->getName()}} @endsection @push('styles') @@ -20,43 +20,43 @@
---|
{{trans('user.name')}} | +{{'Name'}} | {{ $user->getName()}} |
{{trans('user.email')}} | +{{'Email address'}} | {{$user->email}} |
{{trans('user.phonenumber')}} | +{{'Phone number'}} | {{$user->phonenumber}} |
{{trans('user.firstname')}} | +{{'First name'}} | {{ $user->firstname}} |
{{trans('user.preposition')}} | +{{'Preposition'}} | {{ $user->preposition}} |
{{trans('user.lastname')}} | +{{'Last name'}} | {{ $user->lastname}} |
{{trans('user.adress')}} | +{{'Address'}} | {{$user->street . " " . $user->houseNumber}} |
{{trans('user.city')}} | +{{'City'}} | {{$user->city}} |
{{trans('user.zipcode')}} | +{{'Postal code'}} | {{$user->zipcode}} |
{{trans('user.country')}} | +{{'Country'}} | @isset($user->country) {{trans('countries.' . $user->country)}} @@ -138,15 +138,15 @@ |
{{trans('user.phonenumber_alt')}} | +{{'Alternative phone number'}} | {{$user->phonenumber_alt}} |
{{trans('user.birthDay')}} | +{{'Birthdate'}} | {{$user->birthDay}} |
{{trans('user.kind_of_member')}} | +{{'Kind of member'}} | @isset($user->kind_of_member) {{trans('kind_of_member.' . $user->kind_of_member)}} @@ -154,15 +154,15 @@ |
{{trans('user.remark')}} | +{{'Remarks'}} | {{$user->remark}} |
{{trans('user.created_at')}} | +{{'User created at'}} | {{trans(\Carbon\Carbon::parse($user->created_at)->format('d-m-Y'))}} |
{{trans('user.updated_at')}} | +{{'User updated at'}} | {{trans(\Carbon\Carbon::parse($user->updated_at)->format('d-m-Y'))}} |
{{trans('user.IBAN')}} | +{{'IBAN'}} | {{$user->IBAN}} | |
{{trans('user.BIC')}} | +{{'BIC'}} | {{$user->BIC}} | |
{{trans('user.incasso')}} | -{{($user->incasso)? trans('menu.yes') : trans('menu.no')}} | +{{'Accept Automatic Collection'}} | +{{($user->incasso)? 'Yes' : 'No'}} |
{{trans('user.emergencystreet')}} | +{{'Emergency address street'}} | {{$user->emergencystreet}} |
{{trans('user.emergencyHouseNumber')}} | +{{'Emergency address house number'}} | {{$user->emergencyHouseNumber}} |
{{trans('user.emergencyzipcode')}} | +{{'Emergency address postal code'}} | {{$user->emergencyzipcode}} |
{{trans('user.emergencycity')}} | +{{'Emergency address city'}} | {{$user->emergencycity}} |
{{trans('user.emergencycountry')}} | +{{'Emergency address country'}} | {{trans('countries.' . $user->emergencycountry)}} |
{{trans('user.emergencyNumber')}} | +{{'Emergency phone number'}} | {{$user->emergencyNumber}} |
{{trans('user.rols')}} | -{{$user->roles[0]->text->text()}} | +{{'Roles'}} | +{{$user->roles[0]->name}} | ||||
{{$user->roles[$i]->text->text()}} | +{{$user->roles[$i]->name}} | ||||||
- {{trans('certificate.name')}} + {{'Name'}} | - {{trans('certificate.abbreviation')}} + {{'Abbreviation'}} | - {{trans('certificate.duration')}} - | -- {{trans('certificate.validuntil')}} - | -- {{trans('menu.beheer')}} + {{'Management'}} | |||
- {{$certificate->certificateName->text()}} + {{$certificate->name}} | {{$certificate->abbreviation}} | - {{$certificate->duration === null ? "" : $certificate->duration}} - | -- {{$certificate->duration === null ? "" : \Carbon\Carbon::parse($certificate->pivot->startDate)->addMonths($certificate->duration)->format('d-m-Y') }} - | -
-
+
-
+
{{ Form::open(array('url' => '/users/' . $user->id . '/addCertificate/' . $certificate->id, 'method' => 'delete', "id" => "delete-usercertificate-$certificate->id")) }}
{{ Form::close() }}
@@ -281,13 +269,13 @@
- {{trans('user.name')}}
+ {{'Name'}}
|
- {{trans('AgendaItems.startDate')}}
+ {{'Start date'}}
|
- {{trans('menu.action')}}
+ {{'Action'}}
|
{{$curPageName}}-{{trans('validation.Unauthorized')}} +{{'You do not have sufficient access to view this page'}} {{$curPageName}}@endif -{{trans('validation.PageNotFound')}} +{{'Page not found'}} diff --git a/resources/views/errors/killswitch.blade.php b/resources/views/errors/killswitch.blade.php index 5ef18261..fa2d4b79 100644 --- a/resources/views/errors/killswitch.blade.php +++ b/resources/views/errors/killswitch.blade.php @@ -5,7 +5,7 @@{{$curPageName}}-{{trans('front-end/killswitch.text')}} +{{'The website is currently unavailable. For more information, contact the board (bestuur@esac.nl) or the internet committee (ic@esac.nl).'}}
-
{{ $applicationForm->applicationFormName->text() }}+{{ $applicationForm->name }}
-
- {!! Form::submit(trans('menu.submit'), ['class'=> 'btn btn-primary'] ) !!}
- {{trans('menu.cancel')}}
+ {!! Form::submit('Submit', ['class'=> 'btn btn-primary'] ) !!}
+ {{'Cancel'}}
{!! Form::close() !!}
diff --git a/resources/views/forms/inschrijven_admin.blade.php b/resources/views/forms/inschrijven_admin.blade.php
index 3a0f0752..6bd8245c 100644
--- a/resources/views/forms/inschrijven_admin.blade.php
+++ b/resources/views/forms/inschrijven_admin.blade.php
@@ -1,7 +1,7 @@
@extends('layouts.beheer')
@section('title')
-{{$applicationForm->applicationFormName->text()}}
+{{$applicationForm->name}}
@endsection
@section('content')
@@ -10,20 +10,20 @@
{{ csrf_field() }}
-
{{$applicationForm->applicationFormName->text()}}+{{$applicationForm->name}}
- {!! Form::label('user', trans('inschrijven.applicationFormUser')) !!}
+ {!! Form::label('user', 'Member who will be registered:') !!}
{!! Form::select('user',$users,null, ['class' => 'form-control','required' => 'required']) !!}
-
- {!! Form::submit(trans('menu.submit'), ['class'=> 'btn btn-primary'] ) !!}
- {{trans('menu.cancel')}}
+ {!! Form::submit('Submit', ['class'=> 'btn btn-primary'] ) !!}
+ {{'Cancel'}}
{!! Form::close() !!}
diff --git a/resources/views/forms/inschrijven_details.blade.php b/resources/views/forms/inschrijven_details.blade.php
index 7b80807a..4779b5a8 100644
--- a/resources/views/forms/inschrijven_details.blade.php
+++ b/resources/views/forms/inschrijven_details.blade.php
@@ -1,39 +1,39 @@
@extends('layouts.beheer')
@section('title')
-{{trans("ApplicationForm.details")}}
+{{'Application form details'}}
@endsection
@section('content')
-
{{trans("ApplicationForm.details")}}+{{'Application form details'}}
-
{{trans('inschrijven.applicationFormDetailTitle')}}+{{'Details application form'}} |