Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
 
3
namespace Illuminate\Http\Concerns;
4
 
5
use Illuminate\Support\Collection;
6
 
7
trait CanBePrecognitive
8
{
9
    /**
10
     * Filter the given array of rules into an array of rules that are included in precognitive headers.
11
     *
12
     * @param  array  $rules
13
     * @return array
14
     */
15
    public function filterPrecognitiveRules($rules)
16
    {
17
        if (! $this->headers->has('Precognition-Validate-Only')) {
18
            return $rules;
19
        }
20
 
21
        return Collection::make($rules)
22
            ->only(explode(',', $this->header('Precognition-Validate-Only')))
23
            ->all();
24
    }
25
 
26
    /**
27
     * Determine if the request is attempting to be precognitive.
28
     *
29
     * @return bool
30
     */
31
    public function isAttemptingPrecognition()
32
    {
33
        return $this->header('Precognition') === 'true';
34
    }
35
 
36
    /**
37
     * Determine if the request is precognitive.
38
     *
39
     * @return bool
40
     */
41
    public function isPrecognitive()
42
    {
43
        return $this->attributes->get('precognitive', false);
44
    }
45
}