Skip to content

diahnurkhasanah/notes-laravel

Repository files navigation

PAGE LINK ON : notesdiah.fly.dev

laravel new example-app

make db set env

php artisan migrate

//using breeze starter kit for login with sanctum composer require laravel/breeze --dev

//publish all authen php artisan breeze:install

php artisan migrate npm install npm run dev

//make model and migration php artisan make:model Note -m

php artisan migrate

npm install -D tailwindcss postcss autoprefixer npx tailwindcss init -p

//tailwind.config.js content: [ "./resources//*.blade.php", "./resources//.js", "./resources/**/.vue", ],

//./resources/css/app.css @import 'tailwindcss/base'; @import 'tailwindcss/components'; @import 'tailwindcss/utilities';

//at head html @vite('resources/css/app.css')

//install livewire composer require livewire/livewire

//to use ... @livewireStyles

...
@livewireScripts

//trying php artisan make:livewire counter

//make controller php artisan make:controller NoteController

//ngubah route setelah login di routeserviceprovider

Carbon::parse($note->time)->diffForHumans()

{{ \Carbon\Carbon::parse($temp['time'])->diffForHumans() }}

format('Y-m-d H:i:s'); // $time lebih lama dari Carbon now // dd($time < Carbon::now()); $notes = Note::all(); $temps = []; foreach ($notes as $note){ $diff = Carbon::parse($note->time)->diffInMinutes($waktusekarang); $waktunotes = $note->time; if($diff>=0 && $diff<=15 && ($waktunotes>$waktusekarang)){ array_push($temps, $note); // dump($tanggalsekarang); } } // $waktu = Carbon::parse($notes->time); // $tanggalnotes = $notes->time; // dd($tanggalnotes); // $notes = Note::where('user_id', Auth::id())->latest('updated_at')->paginate(5); // $notes = Auth::user()->notes()->latest('updated_at')->paginate(5); $notes = Note::whereBelongsTo(Auth::user())->latest('updated_at')->paginate(5); return view('notes.index')->with(['notes'=> $notes, 'temps' => $temps]); } /** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { return view('notes.create'); } /** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $request->validate([ 'title' => 'required|max:120', 'text' => 'required', 'time' => 'required' ]); Note::create([ 'user_id' => Auth::user()->id, 'uuid' => Str::uuid(), 'title' => $request->title, 'text' => $request->text, 'time' => $request->time ]); return to_route('notes.index'); } /** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show(Note $note) { if(!$note->user->is(Auth::user())) { return abort(403); } return view('notes.show')->with('note', $note); } /** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit(Note $note) { if(!$note->user->is(Auth::user())) { return abort(403); } return view('notes.edit')->with('note', $note); } /** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, Note $note) { if(!$note->user->is(Auth::user())) { return abort(403); } $request->validate([ 'title' => 'required|max:120', 'text' => 'required' ]); $note->update([ 'title' => $request->title, 'text' => $request->text ]); return to_route('notes.show', $note)->with('success','Note updated successfully'); } /** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy(Note $note) { if(!$note->user->is(Auth::user())) { return abort(403); } $note->delete(); return to_route('notes.index')->with('success', 'Note Move to Trash'); } } //tampilan @extends('template.base') @section('title', 'Tambah Data') @section('content') @if($temps)

Hi This Reminder For You!

@foreach ($temps as $temp )
@foreach ($notes as $note)

routeIs('notes.index')) href="{{ route('notes.show', $note) }}" @else href="{{ route('trashed.show', $note) }}" @endif >{{ $note->title }} | {{ \Carbon\Carbon::parse($note->time)->diffForHumans() }}

@endforeach @endforeach
@endif @if(request()->routeIs('notes.index')) @endif @if($notes==null)

{{ Auth::user()->name }}'s notes

@endif @forelse ($notes as $note)

routeIs('notes.index')) href="{{ route('notes.show', $note) }}" @else href="{{ route('trashed.show', $note) }}" @endif >{{ $note->title }}

{{ Str::limit($note->text, 200) }}

{{ $note->updated_at->diffForHumans() }}
@empty @if(request()->routeIs('notes.index'))

You have no notes yet.

make your Own Notes

@else

Nothing Notes in the Trash

@endif @endforelse @endsection //tampilan @if($temps)

Hi This Reminder For You!

@foreach ($temps as $temp )
@foreach ($notes as $note)

routeIs('notes.index')) href="{{ route('notes.show', $note) }}" @else href="{{ route('trashed.show', $note) }}" @endif >{{ $note->title }} | {{ \Carbon\Carbon::parse($note->time)->diffForHumans() }}

@endforeach @endforeach @endif

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published