|  | @@ -0,0 +1,65 @@
 | 
	
		
			
			|  | 1 | +<?php
 | 
	
		
			
			|  | 2 | +
 | 
	
		
			
			|  | 3 | +namespace App\Rules;
 | 
	
		
			
			|  | 4 | +
 | 
	
		
			
			|  | 5 | +use Illuminate\Contracts\Validation\Rule;
 | 
	
		
			
			|  | 6 | +use Illuminate\Contracts\Validation\DataAwareRule;
 | 
	
		
			
			|  | 7 | +
 | 
	
		
			
			|  | 8 | +class TWLimited implements Rule, DataAwareRule
 | 
	
		
			
			|  | 9 | +{
 | 
	
		
			
			|  | 10 | +    protected $data = [];
 | 
	
		
			
			|  | 11 | +    
 | 
	
		
			
			|  | 12 | +    /**
 | 
	
		
			
			|  | 13 | +     * Create a new rule instance.
 | 
	
		
			
			|  | 14 | +     *
 | 
	
		
			
			|  | 15 | +     * @return void
 | 
	
		
			
			|  | 16 | +     */
 | 
	
		
			
			|  | 17 | +    public function __construct()
 | 
	
		
			
			|  | 18 | +    {
 | 
	
		
			
			|  | 19 | +        //
 | 
	
		
			
			|  | 20 | +    }
 | 
	
		
			
			|  | 21 | +
 | 
	
		
			
			|  | 22 | +    /**
 | 
	
		
			
			|  | 23 | +     * Determine if the validation rule passes.
 | 
	
		
			
			|  | 24 | +     *
 | 
	
		
			
			|  | 25 | +     * @param  string  $attribute
 | 
	
		
			
			|  | 26 | +     * @param  mixed  $value
 | 
	
		
			
			|  | 27 | +     * @return bool
 | 
	
		
			
			|  | 28 | +     */
 | 
	
		
			
			|  | 29 | +    public function passes($attribute, $value)
 | 
	
		
			
			|  | 30 | +    {
 | 
	
		
			
			|  | 31 | +        //
 | 
	
		
			
			|  | 32 | +        if (substr($value, 0, 2)=='TW') {
 | 
	
		
			
			|  | 33 | +            if (is_null($this->data['registeredSession'])) {
 | 
	
		
			
			|  | 34 | +                return false;
 | 
	
		
			
			|  | 35 | +            }
 | 
	
		
			
			|  | 36 | +            if (is_null($this->data['lunchOptions'])) {
 | 
	
		
			
			|  | 37 | +                return false;
 | 
	
		
			
			|  | 38 | +            }
 | 
	
		
			
			|  | 39 | +        }
 | 
	
		
			
			|  | 40 | +        return true;
 | 
	
		
			
			|  | 41 | +    }
 | 
	
		
			
			|  | 42 | +
 | 
	
		
			
			|  | 43 | +    /**
 | 
	
		
			
			|  | 44 | +     * Set the data under validation.
 | 
	
		
			
			|  | 45 | +     *
 | 
	
		
			
			|  | 46 | +     * @param  array  $data
 | 
	
		
			
			|  | 47 | +     * @return $this
 | 
	
		
			
			|  | 48 | +     */
 | 
	
		
			
			|  | 49 | +    public function setData($data)
 | 
	
		
			
			|  | 50 | +    {
 | 
	
		
			
			|  | 51 | +        $this->data = $data;
 | 
	
		
			
			|  | 52 | + 
 | 
	
		
			
			|  | 53 | +        return $this;
 | 
	
		
			
			|  | 54 | +    }
 | 
	
		
			
			|  | 55 | +
 | 
	
		
			
			|  | 56 | +    /**
 | 
	
		
			
			|  | 57 | +     * Get the validation error message.
 | 
	
		
			
			|  | 58 | +     *
 | 
	
		
			
			|  | 59 | +     * @return string
 | 
	
		
			
			|  | 60 | +     */
 | 
	
		
			
			|  | 61 | +    public function message()
 | 
	
		
			
			|  | 62 | +    {
 | 
	
		
			
			|  | 63 | +        return 'The validation error message.';
 | 
	
		
			
			|  | 64 | +    }
 | 
	
		
			
			|  | 65 | +}
 |