Issues (68)

src/Mutations/CreateMutation.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace Bakery\Mutations;
4
5
use Bakery\Support\Arguments;
6
use Illuminate\Support\Facades\DB;
7
use Illuminate\Database\Eloquent\Model;
8
9
class CreateMutation extends EloquentMutation
10
{
11
    /**
12
     * Get the name of the mutation.
13
     *
14
     * @return string
15
     */
16
    public function name(): string
17
    {
18
        if (isset($this->name)) {
19
            return $this->name;
20
        }
21
22
        return 'create'.$this->modelSchema->getTypename();
23
    }
24
25
    /**
26
     * Resolve the mutation.
27
     *
28
     * @param Arguments $args
29
     * @return Model
30
     */
31
    public function resolve(Arguments $args): Model
32
    {
33
        $input = $args->input->toArray();
0 ignored issues
show
The property input does not seem to exist on Bakery\Support\Arguments.
Loading history...
34
35
        return DB::transaction(function () use ($input) {
36
            return $this->getModelSchema()->createIfAuthorized($input);
37
        });
38
    }
39
}
40