Skip to content

Instantly share code, notes, and snippets.

@ibrajix
ibrajix / create_todos_table.php
Last active December 22, 2020 15:39
Create new table laravel migration
public function up()
{
Schema::create('test', function (Blueprint $table) {
$table->id();
$table->timestamps();
});
}
public function down()
{
Schema::dropIfExists('test');
@ibrajix
ibrajix / create_column.php
Last active September 3, 2023 07:21
Add new column to migration
public function up()
{
Schema::create('todo', function (Blueprint $table) {
$table->id();
$table->timestamps();
$table->string('name'); //I added the name column
$table->text('description'); //I added the description column
});
}
@ibrajix
ibrajix / app.blade.php
Last active December 23, 2020 17:17
App blade layout laravel
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>
@yield('title')
</title>
@ibrajix
ibrajix / index.blade.php
Last active December 23, 2020 18:54
Show list of todos
@extends('layouts.app')
@section('title')
My Todo App
@endsection
@section('content')
<div class="row mt-3">
<div class="col-12 align-self-center">
<ul class="list-group">
<li class="list-group-item"><a href="details">Dummy todo here</a></li>
@ibrajix
ibrajix / create.blade.php
Last active December 23, 2020 21:39
Create todo
@extends('layouts.app')
@section('title')
Create Todo
@endsection
@section('content')
<form action="" method="post" class="mt-4 p-4">
<div class="form-group m-3">
@ibrajix
ibrajix / details.blade.php
Last active December 23, 2020 18:55
Deatils
@extends('layouts.app')
@section('title')
Details
@endsection
@section('content')
<div class="card text-center mt-5">
<div class="card-header">
@ibrajix
ibrajix / edit.blade.php
Created December 23, 2020 17:44
Edit todo
@extends('layouts.app')
@section('title')
Edit Todo
@endsection
@section('content')
<form action="" method="post" class="mt-4 p-4">
<div class="form-group m-3">
<label for="name">Todo Name</label>
<input type="text" class="form-control" name="" value="Name here">
@ibrajix
ibrajix / index.blade.php
Last active December 23, 2020 21:59
Show all todos
@extends('layouts.app')
@section('title')
My Todo App
@endsection
@section('content')
<div class="row mt-3">
<div class="col-12 align-self-center">
<ul class="list-group">
@foreach($todos as $todo)
@ibrajix
ibrajix / create.blade.php
Created December 23, 2020 21:43
Create todo
<form action="store-data" method="post" class="mt-4 p-4">
@csrf
<div class="form-group m-3">
<label for="name">Todo Name</label>
<input type="text" class="form-control" name="">
</div>
<div class="form-group m-3">
<label for="description">Todo Description</label>
<textarea class="form-control" name="description" rows="3"></textarea>
</div>
@ibrajix
ibrajix / store_data.blade.php
Last active December 23, 2020 22:02
Store Data
public function store(){
try {
$this->validate(request(), [
'name' => ['required'],
'description' => ['required']
]);
} catch (ValidationException $e) {
}