Skip to content

Commit

Permalink
Dashboard basic ui tamamlandı. Modeller eklendi
Browse files Browse the repository at this point in the history
  • Loading branch information
dogukanoksuz committed Nov 8, 2020
1 parent bb2b404 commit 28c0a34
Show file tree
Hide file tree
Showing 23 changed files with 397 additions and 40 deletions.
1 change: 0 additions & 1 deletion client
Submodule client deleted from df3021
2 changes: 1 addition & 1 deletion server/app/Http/Livewire/Document/Create.php
Original file line number Diff line number Diff line change
Expand Up @@ -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!");
Expand Down
13 changes: 13 additions & 0 deletions server/app/Http/Livewire/Document/Edit.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace App\Http\Livewire\Document;

use Livewire\Component;

class Edit extends Component
{
public function render()
{
return view('livewire.document.edit');
}
}
41 changes: 41 additions & 0 deletions server/app/Http/Livewire/Folder/Create.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

namespace App\Http\Livewire\Folder;

use Livewire\Component;
use App\Models\Folder;

class Create extends Component
{
public $isCreatingFolder = false;
public $name = "";
public $message = "";

public function confirmCreatingFolder()
{
$this->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');
}
}
13 changes: 13 additions & 0 deletions server/app/Http/Livewire/Folder/ListContents.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace App\Http\Livewire\Folder;

use Livewire\Component;

class ListContents extends Component
{
public function render()
{
return view('livewire.folder.list-contents');
}
}
27 changes: 27 additions & 0 deletions server/app/Http/Livewire/Folder/Show.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace App\Http\Livewire\Folder;

use Livewire\Component;

class Show extends Component
{
public $folders;

protected $listeners = ['newFolderCreated'];

public function newFolderCreated()
{
$this->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');
}
}
5 changes: 5 additions & 0 deletions server/app/Models/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,9 @@ public function user()
{
return $this->belongsToMany(User::class);
}

public function folder()
{
return $this->belongsTo(Folder::class);
}
}
23 changes: 23 additions & 0 deletions server/app/Models/Folder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Folder extends Model
{
use HasFactory;

protected $fillable = ['name'];

public function user()
{
return $this->belongsToMany(User::class);
}

public function document()
{
return $this->hasMany(Document::class);
}
}
5 changes: 5 additions & 0 deletions server/app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateFoldersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('folders', function (Blueprint $table) {
$table->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');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateFolderUserTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('folder_user', function (Blueprint $table) {
$table->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');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
}
Expand Down
1 change: 1 addition & 0 deletions server/database/seeders/DatabaseSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class DatabaseSeeder extends Seeder
*/
public function run()
{
$this->call(UserSeeder::class);
// \App\Models\User::factory(10)->create();
}
}
24 changes: 24 additions & 0 deletions server/database/seeders/UserSeeder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Hash;
use App\Models\User;

class UserSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
User::create([
'name' => 'Doğukan Öksüz',
'email' => '[email protected]',
'password' => Hash::make('divergent')
]);
}
}
51 changes: 27 additions & 24 deletions server/resources/views/layouts/app.blade.php
Original file line number Diff line number Diff line change
@@ -1,35 +1,38 @@
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="csrf-token" content="{{ csrf_token() }}">

<title>{{ config('app.name', 'Laravel') }}</title>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="csrf-token" content="{{ csrf_token() }}">

<!-- Google Font -->
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap" rel="stylesheet">
<title>{{ config('app.name', 'Laravel') }}</title>

<!-- Styles -->
<link rel="stylesheet" href="{{ asset('css/app.css') }}">
<!-- Google Font -->
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap" rel="stylesheet">

@livewireStyles
<!-- Styles -->
<link rel="stylesheet" href="{{ asset('css/app.css') }}">

<!-- Scripts -->
<script src="https://cdn.jsdelivr.net/gh/alpinejs/[email protected]/dist/alpine.js" defer></script>
</head>
<body class="font-sans antialiased">
<div class="min-h-screen bg-gray-100">
@livewire('navigation-dropdown')
@livewireStyles

<!-- Page Content -->
<main>
{{ $slot }}
</main>
</div>
<!-- Scripts -->
<script src="https://cdn.jsdelivr.net/gh/alpinejs/[email protected]/dist/alpine.js" defer></script>
</head>

@stack('modals')
<body class="font-sans antialiased">
<div class="min-h-screen bg-gray-100">
@livewire('navigation-dropdown')

<!-- Page Content -->
<main>
{{ $slot }}
</main>
</div>

@stack('modals')

@livewireScripts
</body>

@livewireScripts
</body>
</html>
41 changes: 39 additions & 2 deletions server/resources/views/livewire/dashboard.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,49 @@
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
<div>
@if ($message)
<div class="alert alert-success">
{{ $message }}
<div class="mb-5 bg-teal-100 border-t-4 border-teal-500 rounded text-teal-900 px-4 py-3 shadow-md"
role="alert">
<div class="flex">
<div class="py-1"><svg class="fill-current h-6 w-6 text-teal-500 mr-4"
xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
<path
d="M2.93 17.07A10 10 0 1 1 17.07 2.93 10 10 0 0 1 2.93 17.07zm12.73-1.41A8 8 0 1 0 4.34 4.34a8 8 0 0 0 11.32 11.32zM9 11V9h2v6H9v-4zm0-6h2v2H9V5z" />
</svg></div>
<div>
<p class="font-bold mt-1">{{ $message }}</p>
</div>
</div>
</div>
@endif
</div>
<div class="float-left">
<nav class="text-black font-bold my-3" aria-label="Breadcrumb">
<ol class="list-none p-0 inline-flex">
<li class="flex items-center">
<a href="{{ route('dashboard') }}">Pano</a>
<!--<svg class="fill-current w-3 h-3 mx-3" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512">
<path
d="M285.476 272.971L91.132 467.314c-9.373 9.373-24.569 9.373-33.941 0l-22.667-22.667c-9.357-9.357-9.375-24.522-.04-33.901L188.505 256 34.484 101.255c-9.335-9.379-9.317-24.544.04-33.901l22.667-22.667c9.373-9.373 24.569-9.373 33.941 0L285.475 239.03c9.373 9.372 9.373 24.568.001 33.941z" />
</svg>-->
</li>
<!--
<li class="flex items-center">
<a href="#">Second Level</a>
<svg class="fill-current w-3 h-3 mx-3" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512">
<path
d="M285.476 272.971L91.132 467.314c-9.373 9.373-24.569 9.373-33.941 0l-22.667-22.667c-9.357-9.357-9.375-24.522-.04-33.901L188.505 256 34.484 101.255c-9.335-9.379-9.317-24.544.04-33.901l22.667-22.667c9.373-9.373 24.569-9.373 33.941 0L285.475 239.03c9.373 9.372 9.373 24.568.001 33.941z" />
</svg>
</li>
<li>
<a href="#" class="text-gray-500" aria-current="page">Third Level</a>
</li> -->
</ol>
</nav>
</div>
<livewire:document.create />
<livewire:folder.create />

<livewire:folder.show />
<livewire:document.show />
</div>
</div>
3 changes: 2 additions & 1 deletion server/resources/views/livewire/document/create.blade.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<div>
<div class="mb-5 float-right ml-5">
<x-jet-button wire:click="confirmCreating">
<svg class="w-6 h-6 mr-2 -ml-1" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 13h6m-3-3v6m5 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"></path></svg>
Yeni Doküman Oluştur
</x-jet-button>

Expand Down
3 changes: 3 additions & 0 deletions server/resources/views/livewire/document/edit.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div>
{{-- Stop trying to control. --}}
</div>
Loading

0 comments on commit 28c0a34

Please sign in to comment.