public function test_jalali_after_or_before_replacer_is_applied_with_date_and_format()
 {
     $now = '1394-9-15';
     $faNow = StringCleaner::digitsToFarsi($now);
     $validator = $this->factory->make(['graduation_date' => 'garbage'], ['graduation_date' => "required|jalali_after:{$now},Y-m-d|jalali_before:{$now},Y-m-d"]);
     $this->assertTrue($validator->fails());
     $this->assertEquals(['graduation_date' => ["The graduation date must be a Jalali date after {$now}.", "The graduation date must be a Jalali date before {$now}."]], $validator->messages()->toArray());
 }
Beispiel #2
0
 public function sample_5()
 {
     print StringCleaner::digitsToFarsi('1394');
     print "\n";
     print StringCleaner::digitsToEnglish('۱۳۹۴');
     print "\n";
     print StringCleaner::arabicToFarsi('كيك پي اچ پي چيست؟');
     print "\n";
 }
Beispiel #3
0
 public function replaceAfterOrBefore($message, $attribute, $rule, $parameters)
 {
     $format = count($parameters) > 1 ? $parameters[1] : $this->defaultFormat($rule);
     $date = count($parameters) ? $parameters[0] : $this->defaultSampleDate($format, $rule);
     $faDate = StringCleaner::digitsToFarsi($date);
     return str_replace([':date', ':fa-date'], [$date, $faDate], $message);
 }
Beispiel #4
0
 public function test_convert_digits_to_Farsi()
 {
     $this->assertEquals('۰۹۱۳۴۱۰۷', $this->cleaner->digitsToFarsi('09134107'));
     $this->assertEquals('۰۹۱۳۴۱۰۷', $this->cleaner->digitsToFarsi('091341۰7'));
     $this->assertEquals('۰۹۱۳۴۱۰۷abcd', $this->cleaner->digitsToFarsi('091341۰7abcd'));
 }
Beispiel #5
0
 public function replaceAfterOrBefore($message, $attribute, $rule, $parameters)
 {
     $format = count($parameters) > 1 ? $parameters[1] : 'Y/m/d';
     $date = count($parameters) ? $parameters[0] : JalaliDate::fromDateTime(new DateTime())->format($format, false);
     $faDate = StringCleaner::digitsToFarsi($date);
     return str_replace([':date', ':fa-date'], [$date, $faDate], $message);
 }