harvs1789uk

Just as many lines of code I guess, but means it should all be covered in SQL and probably with a "Created" BETWEEN 'X AND 'Y'or just some<=and>=` clauses

harvs1789uk
  1. $Group = GazingaGroup::get()->filter(array(
  2. "Created:GreaterThanOrEqual" => date('Y-m-d') . " 00:00:00",
  3. "Created:LessThanOrEqual" => date('Y-m-d') . " 23:59:59"
  4. ));

https://docs.silverstripe.org/en/4/developer_guides/model/searchfilters/

LiamC

obviously Created has a time so I am trying to format the time out of it

LiamC

I am trying to get groups that were created today

LiamC

Morning, has anyone got a better way / workable way of me achieving the following?

  1. $Date = $Date->format('Y-m-d');
  2. $Group = GazingaGroup::get()->filter(array("Created.Format('Y-m-d')" => $Date));

harvs1789uk

Answered my own question, wrap the SVG in DBHTMLText before pushing in to the ArrayData:

  1. $html = DBHTMLText::create()->setValue($svg);
  2.  
  3. $list->push(ArrayData::create([
  4. 'Chart' => $html,
  5. 'Label' => $label,
  6. 'Value' => $data['PercentageIncluded']
  7. ]));
harvs1789uk

I think this would work if my method had the SVG as it's sole return value:

  1. private static $casting = [
  2. 'MyCustomMethod' => 'HTMLText'
  3. ];

but it returns an ArrayList of ArrayData i.e.

  1. return ArrayList::create([
  2. ArrayData::create(['Chart' => [SVG], 'Label' => 'Some String']),
  3. ArrayData::create(['Chart' => [SVG], 'Label' => 'Some String'])
  4. ]);