The Right Toolbox

The Right Toolbox

Choosing the right tool for the job sometimes means bringing along a whole toolbox. I’ll show how a complex back-end system was built with Craft, Laravel, Redis, and more, all working in harmony.

4b9a52ce862b15437f17695c02c61467?s=128

Anthony Colangelo

April 24, 2014
Tweet

Transcript

  1. 6.
  2. 7.
  3. 8.
  4. 9.
  5. 10.
  6. 11.
  7. 12.
  8. 16.
  9. 20.
  10. 21.
  11. 22.
  12. 23.
  13. 24.
  14. 26.
  15. 27.
  16. 28.
  17. 29.
  18. 30.
  19. 31.
  20. 34.

    // ... } class Nominee extends Eloquent { protected $table

    = 'craft_entries_i18n'; private $sectionId = 2;
  21. 35.

    public function scopeListing($query) { return $query ->select( /* ... */

    ) ->join( /* ... */ ) ->where( /* ... */ ); }
  22. 36.

    public function scopeListing($query) { return $query ->select( /* ... */

    ) ->join('craft_content', 'craft_content.elementId', '=', 'craft_entries_i18n.entryId') ->join('craft_entries', 'craft_entries.id', '=', 'craft_entries_i18n.entryId') ->join('craft_elements', 'craft_elements.id', '=', 'craft_entries_i18n.entryId') ->where('craft_entries_i18n.sectionId','=',$this->sectionId) ->where('craft_entries.postDate','<=',date_format(new DateTime(),'Y-m-d G:i:s')) ->where(function($query) { $query ->where('craft_entries.expiryDate','=',NULL) ->orWhere('craft_entries.expiryDate','>=',date_format(new DateTime(),'Y-m-d G:i:s')); }) ->where('craft_elements.enabled','=',1); }
  23. 44.

    public function scopeListing($query) { return $query ->select( /* ... */

    ) ->join( /* ... */ ) ->where( /* ... */ ); }
  24. 46.
  25. 47.
  26. 48.
  27. 49.
  28. 50.
  29. 51.
  30. 52.
  31. 53.
  32. 54.
  33. 59.
  34. 60.
  35. 61.
  36. 62.
  37. 63.
  38. 64.
  39. 66.

    $redis = Redis::connection('oma4-votes'); ! $voter = "user[{$voterId}]"; $nominee = "nominee[{$nomineeId}]";

    $category = "category[{$categoryId}]"; $influencer = “user[{$influencerId}]”; ! $datetime = new DateTime(); $date['day'] = $datetime->format('Y-m-d'); $date['hour'] = $datetime->format('Y-m-d-H');
  40. 72.
  41. 73.
  42. 74.
  43. 75.
  44. 76.
  45. 77.