404 not found for laravel api Url's - reactjs

I have api call from react to laravel as backend
const response=await fetch("http://localhost:8000/api/getcandidates/");
but I got response as Kanban.jsx:65
GET http://localhost:8000/api/getcandidates/ 404 (Not Found)
and here is my api.php
Route::get('/getcandidates',[EmployeeController::class,'index']);
Route::get('/getcandidates_schedule',[EmployeeController::class,'scheduleresponse']);
Route::get('/getcandidates_rejection',[EmployeeController::class,'rejectionreponse']);
Route::get('/getcandidates_waiting',[EmployeeController::class,'waitingresponse']);
Route::post('/add_employee_first',[EmployeeController::class,'store']);
Route::post('/updatecolumn',[EmployeeController::class,'updatecolumn']);
Route::middleware('auth:api')->get('/user', function (Request $request) {
return $request->user();
});
output of php artisan route:list:
Domain | Method | URI | Name | Action | Middleware |
+--------+----------+----------+------+---------+------------+
| | GET|HEAD | / | | Closure | web |
| | GET|HEAD | api/user | | Closure | api |
| | | | | | auth:api |
+--------+----------+----------+------+---------+------------
Please help me .

Related

Type is missing from type (TS2740) - cant override interface

I have a library called "#ww/react-ui-components"
This library contains Paper component, which extends the functionality of Paper from material ui.
This is how the .d.ts file of my Paper looks like (generated in the build):
import React, { RefObject } from 'react';
import { PaperProps } from '#material-ui/core/Paper';
import { WWAttributesProps } from 'hoc/withWindwardAttributes';
export declare type Props = PaperProps & {
rootElRef?: RefObject<any>;
withHoverEffect?: boolean;
};
declare const _default: React.ForwardRefExoticComponent<Pick<import("../hoc/withWindwardAttributes").Attributes & Pick<PaperProps & {
rootElRef?: React.RefObject<any> | undefined;
withHoverEffect?: boolean | undefined;
} & WWAttributesProps, "slot" | "style" | "title" | "ref" | "classes" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "css" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "component" | "elevation" | "square" | "variant" | "innerRef" | "rootElRef" | "withHoverEffect">, "slot" | "style" | "title" | "classes" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "css" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "component" | "elevation" | "square" | "variant" | "innerRef" | "rootElRef" | "withHoverEffect" | "wwComponentName"> & React.RefAttributes<unknown>>;
export default _default;
I have another library called "#ww/ofv-ui-components" which imports Paper from '#ww/react-ui-components"
When I use it, I get the following error:
Type '{ children: Element; }' is missing the following properties from type 'Pick<Attributes & Pick<any, "placeholder" | "onChange" | "children" | "classes" | "defaultValue" | "defaultChecked" | "suppressContentEditableWarning" | "suppressHydrationWarning" | ... 255 more ... | "withHoverEffect">, "placeholder" | ... 262 more ... | "withHoverEffect">': placeholder, onChange, classes, defaultValue, and 258 more.ts
I tried to override the Paper interface by creating modules.d.ts file in "#ww/ofv-ui-components" and used any just to see if it works - which it didnt.
Is there a way to override it somehow? I dont want to suppress the error or ignore it..
I want to fix it properly

Normalize data in object_construct in Snowflake

I'm using Snowflake's Object_Construct to create a JSON.
Use case: Snowflake table has Person Title as
Person Name
Title_1
Title_2
Title_3
in JSON structure, I need to transform this as
"Person_Title"[
{ "Title_1",
"Title_1_desc"
},
{"Title_2",
"Title_2_desc"
},
{"Title_3",
"Title_3_desc"
}
]
Below example outlines the placement of functions to get the output.
Though not sure if you are looking for any sort of dynamism, which following example does not gives -
with cte (Person_Name, Title_1, Title_2, Title_3) as (
select 'name-1','t1-desc-1','t2-desc-1','t3-desc-1' union all
select 'name-2','t1-desc-2','t2-desc-2','t3-desc-2' union all
select 'name-3','t1-desc-3','t2-desc-3','t3-desc-3'
)
select object_construct('Person_title',
array_construct(
object_construct('Title_1',Title_1),
object_construct('Title_2',Title_2),
object_construct('Title_3',Title_3))) output_json
from cte;
+------------------------------+
| OUTPUT_JSON |
|------------------------------|
| { |
| "Person_title": [ |
| { |
| "Title_1": "t1-desc-1" |
| }, |
| { |
| "Title_2": "t2-desc-1" |
| }, |
| { |
| "Title_3": "t3-desc-1" |
| } |
| ] |
| } |
| { |
| "Person_title": [ |
| { |
| "Title_1": "t1-desc-2" |
| }, |
| { |
| "Title_2": "t2-desc-2" |
| }, |
| { |
| "Title_3": "t3-desc-2" |
| } |
| ] |
| } |
| { |
| "Person_title": [ |
| { |
| "Title_1": "t1-desc-3" |
| }, |
| { |
| "Title_2": "t2-desc-3" |
| }, |
| { |
| "Title_3": "t3-desc-3" |
| } |
| ] |
| } |
+------------------------------+
Query with dynamism -
with cte (Person_Name, Title_1, Title_2, Title_3) as (
select 'name-1','t1-desc-1','t2-desc-1','t3-desc-1' union all
select 'name-2','t1-desc-2','t2-desc-2','t3-desc-2'
)
select object_construct('Person_title',
array_agg(object_construct(TITLE_DESC,TITLE))) as output_col
from
(select * from cte
unpivot (title for title_desc in (Title_1, Title_2, Title_3))
)
group by Person_Name;
+------------------------------+
| OUTPUT_COL |
|------------------------------|
| { |
| "Person_title": [ |
| { |
| "TITLE_1": "t1-desc-1" |
| }, |
| { |
| "TITLE_2": "t2-desc-1" |
| }, |
| { |
| "TITLE_3": "t3-desc-1" |
| } |
| ] |
| } |
| { |
| "Person_title": [ |
| { |
| "TITLE_1": "t1-desc-2" |
| }, |
| { |
| "TITLE_2": "t2-desc-2" |
| }, |
| { |
| "TITLE_3": "t3-desc-2" |
| } |
| ] |
| } |
+------------------------------+

Missing properties in React Typescript component

React component
import {Input} from '#xxx/forms';
<Input label="account Name" name="account"/>
input.d.ts
import React, { Ref } from 'react';
import { InputProps as UITKInputProps } from '#xxx/input';
import { WithStyles, Density } from '#xxx/theme';
import { FormFieldProps as FormFieldPropsType } from '../FormField';
import { NecessityStyle } from '../types';
import styles from './styles';
export declare type InputProps = WithStyles<typeof styles> & UITKInputProps & {
name: string;
label?: string;
id?: string;
disabled?: boolean;
FormFieldProps?: Omit<FormFieldPropsType, 'children' | 'name' | 'label'>;
required?: boolean;
necessityStyle?: NecessityStyle;
helperText?: string;
ref?: Ref<any>;
fullWidth?: boolean;
density?: Density;
};
declare const StyledInput: React.ComponentType<Pick<React.PropsWithChildren<InputProps>, "required" | "disabled" | "error" | "hidden" | "dir" | "label" | "slot" | "style" | "title" | "color" | "ref" | "children" | "onBlur" | "onChange" | "onSubmit" | "name" | "onFocus" | "defaultValue" | "id" | "textAlign" | "translate" | "margin" | "className" | "innerRef" | "defaultChecked" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "draggable" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocusCapture" | "onBlurCapture" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "type" | "fullWidth" | "autoFocus" | "value" | "inputProps" | "inputRef" | "readOnly" | "multiline" | "autoComplete" | "endAdornment" | "inputComponent" | "renderSuffix" | "rows" | "rowsMax" | "rowsMin" | "startAdornment" | "disableUnderline" | "density" | "necessityStyle" | "helperText" | "cursorPositionOnFocus" | "emptyReadOnlyMarker" | "highlightOnFocus" | "FormFieldProps"> & import("#material-ui/styles").StyledComponentProps<"disabled" | "input" | "root" | "readOnly" | "focused" | "multiline" | "inputMultiline" | "endAdornment" | "startAdornment" | "lowDensity" | "touchDensity" | "mediumDensity" | "highDensity" | "field">>;
export { StyledInput as Input };
The only required field for <Input /> is name. However, the compiler is complaining:
Type '{ name: string; }' is missing the following properties from type 'Pick<PropsWithChildren, "ref" | "label" | "slot" | "style" | "title" | "children" | "onBlur" | "onChange" | "onSubmit" | "autoComplete" | ... 276 mo
re ... | "FormFieldProps">': slot, style, title, onBlur, and 267 more.
How can I declare Input component inside my component?
While you didn't provide full type definitions for WithStyles and UITKInputProps I'd guess they are having a lot of required props inside. So your InputProps type gets expanded into a huge list of required props from those two types plus explicitly defined props with a required name field. Thus the error.
If you want your InputProps type to have the only required field name you may define it as:
export declare type InputProps
= Partial<WithStyles<typeof styles>>
& Partial<UITKInputProps>
& {
name: string;
label?: string;
id?: string;
disabled?: boolean;
FormFieldProps?: Omit<FormFieldPropsType, 'children' | 'name' | 'label'>;
required?: boolean;
necessityStyle?: NecessityStyle;
helperText?: string;
ref?: Ref<any>;
fullWidth?: boolean;
density?: Density;
};

Why my laravel passport stopped working when migrated to vagrant from build-in server?

So I had to implement facebook login, which requires https connection, before I was using php artisan serve, but it only allows http, now I decided to migrate whole project to vagrant. Everything works fine but passport.
I checked and found that theese two lines are causing internal error 500
auth()->attempt($loginData, true);
auth()->user()->createToken('authToken')->accessToken;
when removed, I get no error. My whole login function look like this:
public function login(Request $request)
{
$loginData = $request->validate([
'name' => 'required',
'password' => 'required'
]);
$a = auth()->attempt($loginData, true);
if(!$a) {
return response(['message'=>'Invalid credentials', 'auth' => false]);
}
$accessToken = auth()->user()->createToken('authToken')->accessToken;
return response(['user' => auth()->user(), 'access_token' => $accessToken, 'auth' => true, "attempt" => $a, "auth()" => auth()]);
}
In addition, I've created users via tinker, tokens and users were stored.
here is my db data
mysql> select * from users;
+----+-------+--------------------------------------------------------------+----------------+---------------------+---------------------+
| id | name | password | remember_token | created_at | updated_at |
+----+-------+--------------------------------------------------------------+----------------+---------------------+---------------------+
| 1 | admin | $2y$10$V8fM6Vvc7xOJxN/LPyImUeQNzG9/k3tSsaF8qf1NsxrzK9B3VPmsa | NULL | 2019-08-26 15:22:02 | 2019-08-26 15:22:02 |
| 2 | demis | $2y$10$oRvcL0ZC2NQuGXE446GhfO1KBcAw3h8d/TGQmODL/AFHnat1I.Yvq | NULL | 2019-08-26 15:45:27 | 2019-08-26 15:45:27 |
+----+-------+--------------------------------------------------------------+----------------+---------------------+---------------------+
2 rows in set (0.00 sec)
mysql> select * from oauth_access_tokens;
+----------------------------------------------------------------------------------+---------+-----------+-----------+--------+---------+---------------------+---------------------+---------------------+
| id | user_id | client_id | name | scopes | revoked | created_at | updated_at | expires_at |
+----------------------------------------------------------------------------------+---------+-----------+-----------+--------+---------+---------------------+---------------------+---------------------+
| 2e82923d6fdc1cc98580b683952b7b96d555e67d6b7e06b8080f8a55227b6c1d7a755fc21b570941 | NULL | 1 | authToken | [] | 0 | 2019-08-26 15:21:52 | 2019-08-26 15:21:52 | 2020-08-26 15:21:52 |
| 610f8fd1f2212ab257810de88605bff4e419f26477bcf63f8dfe20018d9bcf74797bb9c817d6450a | NULL | 1 | authToken | [] | 0 | 2019-08-26 15:45:19 | 2019-08-26 15:45:19 | 2020-08-26 15:45:19 |
+----------------------------------------------------------------------------------+---------+-----------+-----------+--------+---------+---------------------+---------------------+---------------------+
What's wrong, Why I can't login, maybe there's something wrong with configuration?
Run php artisan passport:install on the new server.

Foreach and getting tags and categories from other tables

I had hard time to think about good title, but I hope that this explains.
Posts table
+----+---------+-----------------+
| id | title | text |
+----+---------+-----------------+
| 1 | Title 1 | This is example |
| 2 | Title 2 | This is example |
| 3 | Title 3 | This is example |
+----+---------+-----------------+
Tags table
+----+--------+
| id | tag |
+----+--------+
| 1 | jQuery |
| 2 | PHP |
| 3 | Stack |
+----+--------+
Category table
+----+------------+
| id | category |
+----+------------+
| 1 | Category 1 |
| 2 | Category 2 |
| 3 | Category 3 |
+----+------------+
Post tags relation table (same thing with category)
+---------+--------+
| post_id | tag_id |
+---------+--------+
| 1 | 1 |
| 1 | 2 |
| 2 | 3 |
+---------+--------+
This is the result what i want to see in my view:
+---------+------------------+--------------------+------------+
| Title | Text | Tags | Categories |
+---------+------------------+--------------------+------------+
| Title 1 | This is example | jQuery, PHP | Category 2 |
| Title 2 | This is example | Stack | Category 1 |
| Title 3 | This is example | jQuery, PHP, Stack | Category 1 |
+---------+------------------+--------------------+------------+
In my controller i have
public function index()
{
$posts = Posts::orderBy('title', 'ASC')->get();
return View::make('posts', array(
'posts' => $posts)
);
}
And in my view I can list all posts with foreach loop
#foreach ($posts as $post)
Title: {{ $post->title }}
Text: {{ $post->text }}
Tags: ?
Categories: ?
#endforeach
Question is that what is best way to get tags and categories for each post inside foreach loop?
Shakil's tips was right on the spot and i found what i was looking for. I am surprised that it was so easy to achieve. Here is what i did:
Posts -model
class Posts extends Eloquent
{
protected $table = 'posts';
public function tags()
{
return $this->belongsToMany('Tags', 'post_tags', 'post_id', 'tag_id');
}
public function category()
{
return $this->belongsToMany('Category', 'post_categories', 'post_id', 'category_id');
}
}
View
#foreach ($posts as $post)
Title: {{ $post->title }}
Text: {{ $post->text }}
Tags:
#foreach ($post->tags as $tag)
{{ $tag }}
#endforeach
Categories:
#foreach ($post->categories as $category)
{{ $category }}
#endforeach
#endforeach
Thanks for all for your help!

Resources