Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Madhu Sudhan Subedi madhusudhan1234

🏠
Working from home
View GitHub Profile
View App.js
import { useEffect, useState } from "react";
import {Navbar, Nav, Form, Button, Table, Container, Modal} from 'react-bootstrap';
import './App.css';
import * as XLSX from "xlsx";
import db from './firebase';
function App() {
const [users, setUsers] = useState([]);
const [show, setShow] = useState(false);
const [headers, setHeaders] = useState([]);
View firebase.js
import firebase from 'firebase'
const firebaseConfig = {
apiKey: process.env.REACT_APP_FIREBASE_API_KEY,
authDomain: process.env.REACT_APP_FIREBASE_AUTH_DOMAIN,
databaseURL: process.env.REACT_APP_FIREBASE_DATABASE_URL,
projectId: process.env.REACT_APP_FIREBASE_PROJECT_ID,
storageBucket: process.env.REACT_APP_FIREBASE_STORAGE_BUCKET,
messagingSenderId: process.env.REACT_APP_FIREBASE_MESSAGING_SENDER_ID,
appId: process.env.REACT_APP_FIREBASE_APP_ID
View .env
REACT_APP_FIREBASE_API_KEY = "XXXXXXXX"
REACT_APP_FIREBASE_AUTH_DOMAIN = "XXXXXXXX"
REACT_APP_FIREBASE_DATABASE_URL = "XXXXXXXX"
REACT_APP_FIREBASE_PROJECT_ID = "XXXXXXXX"
REACT_APP_FIREBASE_STORAGE_BUCKET = "XXXXXXXX"
REACT_APP_FIREBASE_MESSAGING_SENDER_ID = "XXXXXXXX"
REACT_APP_FIREBASE_APP_ID = "XXXXXXXX"
View firebase-config.js
const firebaseConfig = {
apiKey: "XXXXXXXX",
authDomain: "XXXXXXXX",
projectId: "XXXXXXXX",
storageBucket: "XXXXXXXX",
messagingSenderId: "XXXXXXXX",
appId: "XXXXXXXX",
measurementId: "XXXXXXXX"
};
View create-react-app
npx create-react-app import-demo
cd import-demo
npm start
View ReactDataTableApp.js
import React, { Component } from "react";
import DataTable from "./components/DataTable";
export default class ReactDataTableApp extends Component {
constructor(props) {
super(props);
}
render() {
const columns = ['id', 'name', 'email', 'address', 'created_at'];
View UserFactory.php
$factory->define(App\User::class, function (Faker $faker) {
return [
'name' => $faker->name,
'email' => $faker->unique()->safeEmail,
'email_verified_at' => now(),
'address' => $faker->address,
'password' => '$2y$10$TKh8H1.PfQx37YgCzwiKb.KjNyWgaHb9cbcoQgdIVFlYg7B77UdFm', // secret
'remember_token' => str_random(10),
];
});
View UserResource.php
return [
'id' => $this->id,
'name' => $this->name,
'email' => $this->email,
'address' => $this->address,
'created_at' => Carbon::parse($this->created_at)->toDayDateTimeString(),
];
View UserMigration.php
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('email')->unique();
$table->string('address');
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->rememberToken();
View UserController.php
<?php
namespace App\Http\Controllers;
use App\Http\Resources\UsersResource;
use App\User;
use Illuminate\Http\Request;
/**
* Class UsersController