示例#1
0
 public function testImportMessages()
 {
     Message::importMessages(['Hello World!', 'Hello Piñata!']);
     $this->assertNotNull(Message::whereCode('hello.world')->first());
     $this->assertNotNull(Message::whereCode('hello.piñata')->first());
     Message::truncate();
 }
示例#2
0
 public function testImportMessagesCopiesFromDeprecated()
 {
     $this->seedDeprecatedData();
     Message::importMessages(['Hello World!', 'Hello Piñata!']);
     $newMessage = Message::whereCode('hello.piñata')->first();
     $deprecatedMessage = Message::whereCode('hello.pinata')->first();
     $this->assertNotNull($newMessage);
     $this->assertEquals($newMessage->messageData, $deprecatedMessage->messageData);
     Message::truncate();
 }
示例#3
0
 protected function updateGridData($changes)
 {
     if (!is_array($changes)) {
         return;
     }
     foreach ($changes as $change) {
         if (!($code = array_get($change, 'rowData.code'))) {
             continue;
         }
         if (!($columnType = array_get($change, 'keyName'))) {
             continue;
         }
         if ($columnType != 'to' && $columnType != 'from') {
             continue;
         }
         if (!($locale = post('locale_' . $columnType))) {
             continue;
         }
         if (!($item = Message::whereCode($code)->first())) {
             continue;
         }
         $newValue = array_get($change, 'newValue');
         $item->toLocale($locale, $newValue);
     }
 }