From 28c0a34381253a12420a9972f34635e75f98468b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Do=C4=9Fukan=20=C3=96ks=C3=BCz?= Date: Mon, 9 Nov 2020 02:40:53 +0300 Subject: [PATCH] =?UTF-8?q?Dashboard=20basic=20ui=20tamamland=C4=B1.=20Mod?= =?UTF-8?q?eller=20eklendi?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client | 1 - server/app/Http/Livewire/Document/Create.php | 2 +- server/app/Http/Livewire/Document/Edit.php | 13 +++++ server/app/Http/Livewire/Folder/Create.php | 41 +++++++++++++++ .../app/Http/Livewire/Folder/ListContents.php | 13 +++++ server/app/Http/Livewire/Folder/Show.php | 27 ++++++++++ server/app/Models/Document.php | 5 ++ server/app/Models/Folder.php | 23 +++++++++ server/app/Models/User.php | 5 ++ ...2020_11_08_162644_create_folders_table.php | 34 +++++++++++++ ..._11_08_214254_create_folder_user_table.php | 34 +++++++++++++ ...0_11_08_255555_create_documents_table.php} | 4 +- ..._08_255556_create_document_user_table.php} | 0 server/database/seeders/DatabaseSeeder.php | 1 + server/database/seeders/UserSeeder.php | 24 +++++++++ server/resources/views/layouts/app.blade.php | 51 ++++++++++--------- .../views/livewire/dashboard.blade.php | 41 ++++++++++++++- .../views/livewire/document/create.blade.php | 3 +- .../views/livewire/document/edit.blade.php | 3 ++ .../views/livewire/document/show.blade.php | 42 +++++++++++---- .../views/livewire/folder/create.blade.php | 41 +++++++++++++++ .../livewire/folder/list-contents.blade.php | 3 ++ .../views/livewire/folder/show.blade.php | 26 ++++++++++ 23 files changed, 397 insertions(+), 40 deletions(-) delete mode 160000 client create mode 100644 server/app/Http/Livewire/Document/Edit.php create mode 100644 server/app/Http/Livewire/Folder/Create.php create mode 100644 server/app/Http/Livewire/Folder/ListContents.php create mode 100644 server/app/Http/Livewire/Folder/Show.php create mode 100644 server/app/Models/Folder.php create mode 100644 server/database/migrations/2020_11_08_162644_create_folders_table.php create mode 100644 server/database/migrations/2020_11_08_214254_create_folder_user_table.php rename server/database/migrations/{2020_11_08_002528_create_documents_table.php => 2020_11_08_255555_create_documents_table.php} (75%) rename server/database/migrations/{2020_11_08_002551_create_document_user_table.php => 2020_11_08_255556_create_document_user_table.php} (100%) create mode 100644 server/database/seeders/UserSeeder.php create mode 100644 server/resources/views/livewire/document/edit.blade.php create mode 100644 server/resources/views/livewire/folder/create.blade.php create mode 100644 server/resources/views/livewire/folder/list-contents.blade.php create mode 100644 server/resources/views/livewire/folder/show.blade.php diff --git a/client b/client deleted file mode 160000 index df30219..0000000 --- a/client +++ /dev/null @@ -1 +0,0 @@ -Subproject commit df30219e2cf87e62c8e2460500a9bea62e13ac4a diff --git a/server/app/Http/Livewire/Document/Create.php b/server/app/Http/Livewire/Document/Create.php index 7ab4afb..23f80d6 100644 --- a/server/app/Http/Livewire/Document/Create.php +++ b/server/app/Http/Livewire/Document/Create.php @@ -24,7 +24,7 @@ public function createNewDocument() ]); $document->user()->attach(auth()->user()); - } catch (\Exception $e) { + } catch (\Throwable $e) { $this->emitTo('dashboard', 'flashMessage', "Oluşturma işlemi başarısız oldu!"); } $this->emitTo('dashboard', 'flashMessage', $this->name . " isimli doküman başarıyla eklendi!"); diff --git a/server/app/Http/Livewire/Document/Edit.php b/server/app/Http/Livewire/Document/Edit.php new file mode 100644 index 0000000..fd48c15 --- /dev/null +++ b/server/app/Http/Livewire/Document/Edit.php @@ -0,0 +1,13 @@ +isCreatingFolder = true; + } + + public function createNewFolder() + { + try { + $folder = Folder::create([ + 'name' => $this->name + ]); + + $folder->user()->attach(auth()->user()); + } catch (\Throwable $e) { + $this->emitTo('dashboard', 'flashMessage', "Oluşturma işlemi başarısız oldu!"); + } + $this->emitTo('dashboard', 'flashMessage', $this->name . " isimli klasör başarıyla eklendi!"); + + $this->emitTo('folder.show', 'newFolderCreated'); + $this->isCreatingFolder = false; + $this->name = ""; + } + + public function render() + { + return view('livewire.folder.create'); + } +} \ No newline at end of file diff --git a/server/app/Http/Livewire/Folder/ListContents.php b/server/app/Http/Livewire/Folder/ListContents.php new file mode 100644 index 0000000..b2c549c --- /dev/null +++ b/server/app/Http/Livewire/Folder/ListContents.php @@ -0,0 +1,13 @@ +folders = auth()->user()->folder()->orderBy('updated_at', 'DESC')->get(); + } + + public function mount() + { + $this->folders = auth()->user()->folder()->orderBy('updated_at', 'DESC')->get(); + } + + public function render() + { + return view('livewire.folder.show'); + } +} diff --git a/server/app/Models/Document.php b/server/app/Models/Document.php index c024b95..c6f00ee 100644 --- a/server/app/Models/Document.php +++ b/server/app/Models/Document.php @@ -17,4 +17,9 @@ public function user() { return $this->belongsToMany(User::class); } + + public function folder() + { + return $this->belongsTo(Folder::class); + } } diff --git a/server/app/Models/Folder.php b/server/app/Models/Folder.php new file mode 100644 index 0000000..a83b42d --- /dev/null +++ b/server/app/Models/Folder.php @@ -0,0 +1,23 @@ +belongsToMany(User::class); + } + + public function document() + { + return $this->hasMany(Document::class); + } +} diff --git a/server/app/Models/User.php b/server/app/Models/User.php index 81f93df..57e5ca8 100644 --- a/server/app/Models/User.php +++ b/server/app/Models/User.php @@ -59,6 +59,11 @@ class User extends Authenticatable 'profile_photo_url', ]; + public function folder() + { + return $this->belongsToMany(Folder::class); + } + public function document() { return $this->belongsToMany(Document::class); diff --git a/server/database/migrations/2020_11_08_162644_create_folders_table.php b/server/database/migrations/2020_11_08_162644_create_folders_table.php new file mode 100644 index 0000000..b35fd0e --- /dev/null +++ b/server/database/migrations/2020_11_08_162644_create_folders_table.php @@ -0,0 +1,34 @@ +id(); + $table->string('name'); + $table->foreignId('parent_folder_id')->nullable(); + $table->foreign('parent_folder_id')->references('id')->on('folders')->cascadeOnDelete(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('folders'); + } +} diff --git a/server/database/migrations/2020_11_08_214254_create_folder_user_table.php b/server/database/migrations/2020_11_08_214254_create_folder_user_table.php new file mode 100644 index 0000000..3b50e51 --- /dev/null +++ b/server/database/migrations/2020_11_08_214254_create_folder_user_table.php @@ -0,0 +1,34 @@ +id(); + $table->foreignId('folder_id'); + $table->foreignId('user_id'); + $table->foreign('folder_id')->on('folders')->references('id')->cascadeOnDelete(); + $table->foreign('user_id')->on('users')->references('id')->cascadeOnDelete(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('folder_user'); + } +} diff --git a/server/database/migrations/2020_11_08_002528_create_documents_table.php b/server/database/migrations/2020_11_08_255555_create_documents_table.php similarity index 75% rename from server/database/migrations/2020_11_08_002528_create_documents_table.php rename to server/database/migrations/2020_11_08_255555_create_documents_table.php index 97b9c5f..dff9e28 100644 --- a/server/database/migrations/2020_11_08_002528_create_documents_table.php +++ b/server/database/migrations/2020_11_08_255555_create_documents_table.php @@ -16,7 +16,9 @@ public function up() Schema::create('documents', function (Blueprint $table) { $table->id(); $table->string('name'); - $table->longText('content'); + $table->longText('content')->nullable(); + $table->foreignId('folder_id')->nullable(); + $table->foreign('folder_id')->references('id')->on('folders')->cascadeOnDelete(); $table->timestamps(); }); } diff --git a/server/database/migrations/2020_11_08_002551_create_document_user_table.php b/server/database/migrations/2020_11_08_255556_create_document_user_table.php similarity index 100% rename from server/database/migrations/2020_11_08_002551_create_document_user_table.php rename to server/database/migrations/2020_11_08_255556_create_document_user_table.php diff --git a/server/database/seeders/DatabaseSeeder.php b/server/database/seeders/DatabaseSeeder.php index 57b73b5..6b41bc5 100644 --- a/server/database/seeders/DatabaseSeeder.php +++ b/server/database/seeders/DatabaseSeeder.php @@ -13,6 +13,7 @@ class DatabaseSeeder extends Seeder */ public function run() { + $this->call(UserSeeder::class); // \App\Models\User::factory(10)->create(); } } diff --git a/server/database/seeders/UserSeeder.php b/server/database/seeders/UserSeeder.php new file mode 100644 index 0000000..5a2adb4 --- /dev/null +++ b/server/database/seeders/UserSeeder.php @@ -0,0 +1,24 @@ + 'Doğukan Öksüz', + 'email' => 'me@dogukan.dev', + 'password' => Hash::make('divergent') + ]); + } +} diff --git a/server/resources/views/layouts/app.blade.php b/server/resources/views/layouts/app.blade.php index 19b0fc3..a2a8a36 100644 --- a/server/resources/views/layouts/app.blade.php +++ b/server/resources/views/layouts/app.blade.php @@ -1,35 +1,38 @@ - - - - - {{ config('app.name', 'Laravel') }} + + + + - - + {{ config('app.name', 'Laravel') }} - - + + - @livewireStyles + + - - - - -
- @livewire('navigation-dropdown') + @livewireStyles - -
- {{ $slot }} -
-
+ + + - @stack('modals') + +
+ @livewire('navigation-dropdown') + + +
+ {{ $slot }} +
+
+ + @stack('modals') + + @livewireScripts + - @livewireScripts - diff --git a/server/resources/views/livewire/dashboard.blade.php b/server/resources/views/livewire/dashboard.blade.php index b0d8f64..6b72226 100644 --- a/server/resources/views/livewire/dashboard.blade.php +++ b/server/resources/views/livewire/dashboard.blade.php @@ -2,12 +2,49 @@
@if ($message) -
- {{ $message }} + @endif
+
+ +
+ + +
diff --git a/server/resources/views/livewire/document/create.blade.php b/server/resources/views/livewire/document/create.blade.php index 12eac71..3d1ab26 100644 --- a/server/resources/views/livewire/document/create.blade.php +++ b/server/resources/views/livewire/document/create.blade.php @@ -1,5 +1,6 @@ -
+
+ Yeni Doküman Oluştur diff --git a/server/resources/views/livewire/document/edit.blade.php b/server/resources/views/livewire/document/edit.blade.php new file mode 100644 index 0000000..ad58cc8 --- /dev/null +++ b/server/resources/views/livewire/document/edit.blade.php @@ -0,0 +1,3 @@ +
+ {{-- Stop trying to control. --}} +
diff --git a/server/resources/views/livewire/document/show.blade.php b/server/resources/views/livewire/document/show.blade.php index a8e2a00..6210afd 100644 --- a/server/resources/views/livewire/document/show.blade.php +++ b/server/resources/views/livewire/document/show.blade.php @@ -1,13 +1,35 @@ -
-
- Fetching Documents... +
+
+
-
- @foreach ($documents as $document) - - {{ $document->name }}
- {{ $document->updated_at->isoFormat('LLL') }}
-

- @endforeach +
diff --git a/server/resources/views/livewire/folder/create.blade.php b/server/resources/views/livewire/folder/create.blade.php new file mode 100644 index 0000000..c695458 --- /dev/null +++ b/server/resources/views/livewire/folder/create.blade.php @@ -0,0 +1,41 @@ +
+ + + Yeni Klasör Oluştur + + + + + Yeni Klasör Oluştur + + + + @if (!empty($message)) + + @endif + Oluşturmak istediğiniz klasörün ismini yazınız. + + +
+ +
+
+ + + + {{ __('Close') }} + + + + {{ __('Create') }} + + +
+
diff --git a/server/resources/views/livewire/folder/list-contents.blade.php b/server/resources/views/livewire/folder/list-contents.blade.php new file mode 100644 index 0000000..a40248d --- /dev/null +++ b/server/resources/views/livewire/folder/list-contents.blade.php @@ -0,0 +1,3 @@ +
+ {{-- Knowing others is intelligence; knowing yourself is true wisdom. --}} +
diff --git a/server/resources/views/livewire/folder/show.blade.php b/server/resources/views/livewire/folder/show.blade.php new file mode 100644 index 0000000..81c6625 --- /dev/null +++ b/server/resources/views/livewire/folder/show.blade.php @@ -0,0 +1,26 @@ +
+
+ +
+
+ @foreach ($folders as $folder) + + @endforeach +
+