Commit 7b20d442 authored by Dillenn Terumalai's avatar Dillenn Terumalai
Browse files

Wrote the README and final status of the app

parent 6d7676a2
This diff is collapsed.
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Category extends Model
{
protected $table = 'categories';
public function todos()
{
return $this->hasMany('App\Todo');
}
}
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class HomeController extends Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
}
/**
* Show the application dashboard.
*
* @return \Illuminate\Contracts\Support\Renderable
*/
public function index()
{
return view('home');
}
}
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Todo;
class TodoController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$categories = \App\Category::all();
$tags = \App\Tag::all();
$todos = Todo::with(['category', 'tags'])->orderBy('id', 'desc')->get();
return view('todos')->with(compact('categories', 'tags', 'todos'));
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
//
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$category = \App\Category::find($request->category); //We retrieve the row of the category
$todo = new Todo; //We create a new model of Todo
$todo->task = $request->task; //We set it's task field to the request's task field
$todo->category()->associate($category); //We associate our Todo with the category
$todo->save(); //We save it in the Database
$todo->tags()->attach($request->tags); //We create links between our Todo and tags
return redirect()->action('TodoController@index'); //We now redirect to the index function
}
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
return Todo::with(['category', 'tags'])->find($id);
}
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function edit($id)
{
//
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
$todo = Todo::find($id); //We retrieve the row of the todo
$todo->done = !$todo->done; //We switch its status
$todo->save(); //We update the row
return redirect()->action('TodoController@index'); //We now redirect to the index function
}
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
Todo::destroy($id); //We destroy our row by using the id
return redirect()->action('TodoController@index'); //We now redirect to the index function
}
}
...@@ -19,6 +19,6 @@ class VerifyCsrfToken extends Middleware ...@@ -19,6 +19,6 @@ class VerifyCsrfToken extends Middleware
* @var array * @var array
*/ */
protected $except = [ protected $except = [
// 'http://localhost/*'
]; ];
} }
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Tag extends Model
{
public function todos()
{
return $this->belongsToMany('App\Todo');
}
}
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Todo extends Model
{
public function category()
{
return $this->belongsTo('App\Category');
}
public function tags()
{
return $this->belongsToMany('App\Tag');
}
}
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
"require-dev": { "require-dev": {
"facade/ignition": "^1.4", "facade/ignition": "^1.4",
"fzaninotto/faker": "^1.4", "fzaninotto/faker": "^1.4",
"laravel/ui": "^1.1",
"mockery/mockery": "^1.0", "mockery/mockery": "^1.0",
"nunomaduro/collision": "^3.0", "nunomaduro/collision": "^3.0",
"phpunit/phpunit": "^8.0" "phpunit/phpunit": "^8.0"
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "a58a97ff47f1f23921f11f3b36cbe32b", "content-hash": "2bd2f04870b50f632ea21825eb1d9d23",
"packages": [ "packages": [
{ {
"name": "dnoegel/php-xdg-base-dir", "name": "dnoegel/php-xdg-base-dir",
...@@ -3370,6 +3370,63 @@ ...@@ -3370,6 +3370,63 @@
], ],
"time": "2016-01-20T08:20:44+00:00" "time": "2016-01-20T08:20:44+00:00"
}, },
{
"name": "laravel/ui",
"version": "v1.1.1",
"source": {
"type": "git",
"url": "https://github.com/laravel/ui.git",
"reference": "57e2361b55ed1bc80ff0b3258b9713626fb38a2b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel/ui/zipball/57e2361b55ed1bc80ff0b3258b9713626fb38a2b",
"reference": "57e2361b55ed1bc80ff0b3258b9713626fb38a2b",
"shasum": ""
},
"require": {
"illuminate/console": "~5.8|^6.0",
"illuminate/filesystem": "~5.8|^6.0",
"illuminate/support": "~5.8|^6.0",
"php": "^7.1.3"
},
"require-dev": {
"mockery/mockery": "^1.0",
"phpunit/phpunit": "^8.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.x-dev"
},
"laravel": {
"providers": [
"Laravel\\Ui\\UiServiceProvider"
]
}
},
"autoload": {
"psr-4": {
"Laravel\\Ui\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Taylor Otwell",
"email": "taylor@laravel.com"
}
],
"description": "Laravel UI utilities and presets.",
"keywords": [
"laravel",
"ui"
],
"time": "2019-10-11T12:16:52+00:00"
},
{ {
"name": "mockery/mockery", "name": "mockery/mockery",
"version": "1.2.4", "version": "1.2.4",
......
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateCategoriesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('categories', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('title');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('categories');
}
}
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateTodosTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('todos', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('task');
$table->boolean('done')->default(false);
$table->unsignedBigInteger('category_id')->nullable();
$table->foreign('category_id')
->references('id')->on('categories')
->onUpdate('cascade')
->onDelete('cascade');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('todos');
}
}
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateTagsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('tags', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('title');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('tags');
}
}
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateTagTodoTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('tag_todo', function (Blueprint $table) {
$table->unsignedBigInteger('tag_id');
$table->foreign('tag_id')
->references('id')->on('tags')
->onUpdate('cascade')
->onDelete('cascade');
$table->unsignedBigInteger('todo_id');
$table->foreign('todo_id')
->references('id')->on('todos')
->onUpdate('cascade')
->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('tag_todo');
}
}
...@@ -11,11 +11,16 @@ ...@@ -11,11 +11,16 @@
}, },
"devDependencies": { "devDependencies": {
"axios": "^0.19", "axios": "^0.19",
"bootstrap": "^4.0.0",
"cross-env": "^5.1", "cross-env": "^5.1",
"jquery": "^3.2",
"laravel-mix": "^4.0.7", "laravel-mix": "^4.0.7",
"lodash": "^4.17.13", "lodash": "^4.17.13",
"popper.js": "^1.12",
"resolve-url-loader": "^2.3.1", "resolve-url-loader": "^2.3.1",
"sass": "^1.15.2", "sass": "^1.20.1",
"sass-loader": "^7.1.0" "sass-loader": "7.*",
"vue": "^2.5.17",
"vue-template-compiler": "^2.6.10"
} }
} }
/**
* First we will load all of this project's JavaScript dependencies which
* includes Vue and other libraries. It is a great starting point when
* building robust, powerful web applications using Vue and Laravel.
*/
require('./bootstrap'); require('./bootstrap');
window.Vue = require('vue');
/**
* The following block of code may be used to automatically register your
* Vue components. It will recursively scan this directory for the Vue
* components and automatically register them with their "basename".
*
* Eg. ./components/ExampleComponent.vue -> <example-component></example-component>
*/
// const files = require.context('./', true, /\.vue$/i)
// files.keys().map(key => Vue.component(key.split('/').pop().split('.')[0], files(key).default))
Vue.component('example-component', require('./components/ExampleComponent.vue').default);
/**
* Next, we will create a fresh Vue application instance and attach it to
* the page. Then, you may begin adding components to this application
* or customize the JavaScript scaffolding to fit your unique needs.
*/
const app = new Vue({
el: '#app',
});
window._ = require('lodash'); window._ = require('lodash');
/**
* We'll load jQuery and the Bootstrap jQuery plugin which provides support
* for JavaScript based Bootstrap features such as modals and tabs. This
* code may be modified to fit the specific needs of your application.
*/
try {
window.Popper = require('popper.js').default;
window.$ = window.jQuery = require('jquery');
require('bootstrap');
} catch (e) {}
/** /**
* We'll load the axios HTTP library which allows us to easily issue requests * We'll load the axios HTTP library which allows us to easily issue requests
* to our Laravel back-end. This library automatically handles sending the * to our Laravel back-end. This library automatically handles sending the
......
<template>
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<div class="card-header">Example Component</div>
<div class="card-body">
I'm an example component.
</div>
</div>
</div>
</div>
</div>
</template>
<script>
export default {
mounted() {
console.log('Component mounted.')
}
}
</script>
// Body
$body-bg: #f8fafc;
// Typography
$font-family-sans-serif: 'Nunito', sans-serif;
$font-size-base: 0.9rem;
$line-height-base: 1.6;
// Colors
$blue: #3490dc;
$indigo: #6574cd;
$purple: #9561e2;
$pink: #f66d9b;
$red: #e3342f;
$orange: #f6993f;
$yellow: #ffed4a;
$green: #38c172;
$teal: #4dc0b5;
$cyan: #6cb2eb;
// // Fonts
@import url('https://fonts.googleapis.com/css?family=Nunito');
// Variables
@import 'variables';
// Bootstrap
@import '~bootstrap/scss/bootstrap';
@extends('layouts.app')
@section('content')
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<div class="card-header">{{ __('Login') }}</div>
<div class="card-body">
<form method="POST" action="{{ route('login') }}">
@csrf
<div class="form-group row">
<label for="email" class="col-md-4 col-form-label text-md-right">{{ __('E-Mail Address') }}</label>
<div class="col-md-6">
<input id="email" type="email" class="form-control @error('email') is-invalid @enderror" name="email" value="{{ old('email') }}" required autocomplete="email" autofocus>
@error('email')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="form-group row">
<label for="password" class="col-md-4 col-form-label text-md-right">{{ __('Password') }}</label>
<div class="col-md-6">
<input id="password" type="password" class="form-control @error('password') is-invalid @enderror" name="password" required autocomplete="current-password">
@error('password')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>