app/Api/V1/Controllers/TaskTypeController.php
/**
     * create new task type
     *
     * @param Request $request
     * @return TaskType
     * @throws \Illuminate\Validation\ValidationException
     */
create new task type
@param Request $request
@return TaskType
@throws \Illuminate\Validation\ValidationException
create new task type @param Request $request @return TaskType @throws \ Illuminate \ Validation \ ValidationException
public function store(Request $request)
    {
        $this->validate($request, [
            'name' => 'required|string|unique:task_types,name',
            'description' => 'string|nullable'
        ], ['name.unique' => 'Task type already exists']);
        $data = $request->only('name', 'description');
        $taskType = new TaskType($data);
        if ($taskType->save()) {
            return $taskType;
        }
        throw new StoreResourceFailedException('Task type couldn\'t be stored');
    }
public function store ( Request $ request ) { $ this -> validate ( $ request , [ 'name' => 'required|string|unique:task_types,name' , 'description' => 'string|nullable' ] , [ 'name.unique' => 'Task type already exists' ] ) ; $ data = $ request -> only ( 'name' , 'description' ) ; $ taskType = new TaskType ( $ data ) ; if ( $ taskType -> save ( ) ) { return $ taskType ; } throw new StoreResourceFailedException ( 'Task type couldn\'t be stored' ) ; }
create new task type
 @param Request $request
 @return TaskType
 @throws \Illuminate\Validation\ValidationException
create new task type @param Request $request @return TaskType @throws \ Illuminate \ Validation \ ValidationException