Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure want to rename?
peripherad
/
app
/
Rules
:
ValidateDate.php
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
<?php namespace App\Rules; use Carbon\Carbon; use Illuminate\Contracts\Validation\InvokableRule; class ValidateDate implements InvokableRule { public function __invoke($attribute, $value, $fail) { if ($attribute == 'date_scheduled') $message = 'The date scheduled can not be weekend.'; else if ($attribute == 'delivery_date') $message = 'The delivery date can not be weekend.'; else $message = 'The date pick up / ship by can not be weekend.'; try { $date = Carbon::make($value); if ($date->isWeekend()) $fail($message); } catch (\Exception $e){ // $fail('The :attribute is not a valid date.'); } } }