Example #1
0
 public static function table_columns($table = null)
 {
     return array('name', 'Birthdate' => function ($row) {
         return date('d-M Y', strtotime($row->birth_date));
     }, 'lead_source' => array('heading' => 'Lead Source', 'value' => function ($row) {
         return Client::select_value('lead_source', $row->lead_source);
     }));
 }
Example #2
0
 /**
  * Test shorthand
  *
  * @return void
  */
 public function testShorthand()
 {
     $clients = Client::all();
     $columns = array('name', 'Birthdate' => function ($row) {
         return date('d-M Y', strtotime($row->birth_date));
     }, 'lead_source' => array('heading' => 'Lead Source', 'value' => function ($row) {
         return Client::select_value('lead_source', $row->lead_source);
     }));
     $expected_horizontal = $this->markup('classconfig_horizontal');
     $expected_vertical = $this->markup('classconfig_vertical');
     $table = Squi\Table::make($columns, $clients, 'vertical');
     $this->assertSame($expected_vertical, $table->render());
     $table = Squi\Table::horizontal($columns, $clients);
     $this->assertSame($expected_horizontal, $table->render());
     $table = Squi\Table::vertical($columns, $clients);
     $this->assertSame($expected_vertical, $table->render());
     $table = Squi\Table::of('Client', $clients, 'summary_columns');
     $expected = $this->markup('classconfig_summary');
     $this->assertSame($expected, $table->render());
     $table = Squi\Table::of($clients);
     $this->assertSame($expected_horizontal, $table->render());
     $table = Squi\Table::of('Client', $clients);
     $this->assertSame($expected_horizontal, $table->render());
 }