Jump to content

Database constraints and building an admin area


Pete Jones
 Share

Recommended Posts

We are currently looking at building a custom administration area with the basic outlined functionality. Users will be able to login and see their horses, their events and their payments. Admins will be able to login and see all users, horses, events, payments. Data structure below.

Questions

1) Would this make sense to build as a single frontend with different 'admin' levels' rather than customising the backend of PW? Ultimately the PW install will be running a full frontend website (showing Horses for Sale, Events and other misc content) so users will need to login to update content.

2) How does PW handle database relationships? Could this structure be built?

Users
------

ID
Email

Horses - one user can own many horses
-------

ID
UserID
Membership Level (payment)

Events - one horse can enter many events
-------

ID
HorseID
Required Membership Level

Payments
-----

ID
TransactionID

Payment Items - one payment can have many payment items
----

ID
PaymentID
Order Type - Horse Registration/Donation/Event
ItemID - HorseID, DonationID, EventID
Cost
VAT

 

Many thanks

Pete

 

Link to comment
Share on other sites

Sure, there are just no database backed constraints. The benefit of building a custom frontend is also the biggest drawback: It's custom. In the backend you can harness a lot of already existing functionality, which works if that's how you need to handle things, but might get messy if you need to work against it almost everywhere.

  • Like 2
Link to comment
Share on other sites

Right, so let's just say we have a members area which holds all of the User/Horse/Payment details and a CMS. Is there a way in which we can have a single point of access for all this? We've been discussing perhaps a Laravel user/horse system and expose some JSON for the website area.

What I don't want to to provide 2 'admin' system to the client. One for users/horses and one for the CMS.

Link to comment
Share on other sites

Hey Pete,

What kind of functionality do these subsystems have? I don't see anything  that you couldn't build in the admin. 
On a smaller scale, but somewhat related, I have a help desk system that has some similar relationships.

Users
There are about 20 fields associated with each user

Tickets
Each user can have multiple tickets

Equipment
Each ticket can have multiple pieces of equipment attached.
The equipment may be assigned to the user, or it may not be.

Those sound like they are similar to your User/Horses/Events
Although, I don't have anything that's analogous to the payments

You can build some pretty complex stuff in the admin, but if you have a lot of custom UI requirements, then you might end up fighting against it like LostKobrakai mentioned. I don't know if that gives you anything more to go on other than, "Hey, I've done something *kind of* similar". :)

  • Like 1
Link to comment
Share on other sites

Wow.

Can I ask how you built the data structure? Was this all through processwire and pages?

Did you customise the PW admin area or is this entirely frontend?

Having tried to build a basic proof of concept the data structure it's tough to amek the admin area work sensibly.

 

Pete

Link to comment
Share on other sites

Hey Pete,

It's all a combination of Pages and FormBuilder. Although, there's no need to use FB, I was just piggy-backing on some other systems I built. You could do all the same stuff without FB at all.

Short explanation: We have lots of these systems, and there are even multiple Help Desk types, so there would have been hundreds of PW fields. Instead we use FormBuilder for creating the input method, and then send certain parts of the data to a PW page. It probably sounds complicated, but it's really not.

Ultimately everything is a page. The relationships are maintained with Page fields. InputfieldMarkup provides a way to display some of the related data (like the effected equipment list) in whatever format we need. It makes it fairly easy to style it however you'd like.

  • Like 2
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Similar Content

    • By jom
      Chäs & Co is a b2b cheese trader. They love good cheese and are proud of their excellent knowledge und connections to small cheese producers. They maintain a custom made database and used to copy/paste (!) the cheese infos to the former CMS (Contao). Since substituting the database with ProcessWire was no option, they export now the database to a csv file and import it to the new website (expanded version of module ImportPagesCSV).
      From there, the pw magic begins. The staff works with the admin interface: They search and find products in notime using the build-in search field (using cheese names or id. Using ids only possible by adding hook, see this forum thread). They generate price lists easily based on a template, providing checkboxes and option buttons for some restrictions, choose i.e. the cheese origin and price audience (all implemented as page selectors). By saving the page a PDF list gets generated (using mpdf, a php pdf library).
      The visitors can sort and filter the products using a form by shuffle.js. Product details are shown in a popup (fancybox). There's also the option for generating a nice pdf data sheet. No CSS framework being used.
      Other modules used: ProcessJumpLinks, ProcessProMailer, ProcessWireUpgrade.
      Visual design: Nicole Haller


    • By markus_blue_tomato
      Did anybody here developed a ProcessWire Site with Recurring Payments / Subscriptions?
      I have an idea for an B2B service where companies can register themselves and if they have an active subscription they can access some specific content. They can also cancel the subscription every month.
      I looked and SnipWire/FormBuilder but found nothing about Recurring Payments.
    • By Juergen
      Hello @ all,
      I am creating a new inputfield/fieldtype to store opening hours, but I am struggeling to save values from multiple dynamic created inputfields in 1 column of the database.
      Scenario:
      The user can enter one or more opening times per day in a UI.
      Fe:
      Monday open from 08:00 to 12:00 and from 14:00 to 17:00 Tuesday open from 08:00 to 12:00 and from 14:00 to 19:00 and so on
      Via a little JavaScript you can add as much opening times as you need per day - the additional inputfield will be created dynamically.
      After form submission all the values are in the POST array -> this works (see example below):
      ProcessWire\WireInputData Object ( [openinghours_mo-0-start] => 09:00 [openinghours_mo-0-finish] => 13:00 [openinghours_mo-1-start] => 14:00 [openinghours_mo-1-finish] => 18:00 [openinghours_mo-2-start] => 21:00 [openinghours_mo-2-finish] => 23:00 [openinghours_tu-0-start] => 09:00 [openinghours_tu-0-finish] => 13:00 [openinghours_tu-1-start] => 14:00 [openinghours_tu-1-finish] => 18:00 [openinghours_we-0-start] => 09:00 [openinghours_we-0-finish] => 13:00 [openinghours_we-1-start] => 14:00 [openinghours_we-1-finish] => 18:00 [openinghours_th-0-start] => 09:00 [openinghours_th-0-finish] => 13:00 [openinghours_th-1-start] => 14:00 [openinghours_th-1-finish] => 18:00 [openinghours_fr-0-start] => 09:00 [openinghours_fr-0-finish] => 13:00 [openinghours_fr-1-start] => 14:00 [openinghours_fr-1-finish] => 18:00 [openinghours_sa-0-start] => [openinghours_sa-0-finish] => [openinghours_so-0-start] => [openinghours_so-0-finish] => ) The property name is always the name attribute of the field 😉 . If the property is empty means closed on that day.
      Now I need to combine all those values into 1 array (or json array) and store it in the database in 1 column called 'hours' in my case (see screenshot below):

      In my ___processInput(WireInputData $input) method I have tried to make it work like this:
      public function ___processInput(WireInputData $input): self { $name = $this->attr('name'); $value = $this->attr('value'); //input object includes always every input on the page, so lets filter out only inputs from this field //we need to do this, because the number of values is variable - so extract only values that starts with $name.'_' $nameAttributes = []; foreach($input as $key=>$value){ if(substr($key, 0, strlen($name.'_')) === $name.'_'){ $nameAttributes[$key] = $value; } } // loop through all inputfields of this fieldtype $time_values = []; foreach($nameAttributes as $nameAttr => $value) { $time_values[$nameAttr] = $value; } } //save it in the database $input->set('hours', serialize($time_values)); return $this; } The only important part of this code is the last part with the serialize function.
      After saving it will create a record in the database, but the value is always NULL (default value) (see below).

      Checking $time_values returns all the values, but printing out "$this" shows me that the property "hours" inside the Openinghours object is empty (see below) - so the mistake must be there, but I dont know where?!?!?!?
      [title] => Home [openinghours] => ProcessWire\OpeningHours Object ( [data] => Array ( [hours] => ) ) If I check the sleepValue() method or the sanitizeValue() - they are also empty. So it seems that the values will not reach these methods. I havent found a clear documentation of whats going on behind the saving process of an inputfield.
      As far as I know the saving process starts with the form submission. The values are in the POST array and will be processed by the processInput() method. Before they will be saved in the database they will be sanitized by the sanitizeValue() mehtod and afterwards they will be prepared for storage in the sleepValue() method.  The last step is the storage itself.
      Has someone an idea what is missing by storing values from multiple fields into 1 database column or has someone a working example of such a scenario on github to help me out.
      A clear explanation of the storage process will be also helpful.
      Thanks and best regards
    • By Pip
      Hi Everyone 
      I've been working on Processwire for two months now. Structuring the website as needed. Unsure why but I'm getting this one now. Seems my fields has crashed. 
      I've tried googling some answers but can't seem to find a step by step guide on how to rectify this. Any advise? Practically new on this. 
      TIA. 

    • By Rodd
      Hi everyone!
      I have a website in a production environment and I want to duplicate it in a local environment. I exported the content of the website (with the 'Site Profile Exporter' module) but I cannot use it actually. I've got an issue with the database. I imported this one in MAMP then.

      I also exported the pages (with the 'ProcessPagesExportImport' module), but I cannot import it to my local website because the fields don't exist. So I created this fields, but I have this error :
      How can I use the elements that already exist and are presents in my database? How can I duplicate correctly the templates, fields and pages?
      Thanks by advance
      PS: Sorry if my english is bad
       
×
×
  • Create New...