Projects begin

This commit is contained in:
Александр Бабкин
2022-06-27 16:55:01 +03:00
parent 310613e9a8
commit 34f6fa7733
10 changed files with 359 additions and 6 deletions

View File

@@ -0,0 +1,86 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\Project;
class ProjectController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$projects = Project::all();
return view('projects.list', ['projects' => $projects]);
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
return view('projects.create');
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
//
}
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($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)
{
//
}
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
//
}
}

15
app/Models/Project.php Normal file
View File

@@ -0,0 +1,15 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Project extends Model
{
use HasFactory;
protected $fillable = [
'name',
'description',
];
}

View File

@@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateProjectsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('projects', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('description');
$table->timestamps();
$table->softDeletes();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('projects');
}
}

View File

@@ -23,6 +23,11 @@
</x-nav-link>
@endif
</div>
<div class="hidden space-x-8 sm:-my-px sm:ml-10 sm:flex">
<x-nav-link :href="route('projects.index')" :active="request()->routeIs('projects.index')|request()->routeIs('projects.create')|request()->routeIs('projects.show')|request()->routeIs('projects.edit')">
{{ __('Projects') }}
</x-nav-link>
</div>
</div>
<!-- Settings Dropdown -->

View File

@@ -0,0 +1,60 @@
<x-app-layout>
<x-slot name="header">
<h2 class="font-semibold text-xl text-gray-800 leading-tight">
{{ __('Create user') }}
</h2>
</x-slot>
<div class="py-12">
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
<div class="bg-white overflow-hidden shadow-sm sm:rounded-lg">
<div class="p-6 bg-white border-b border-gray-200">
<form method="POST" action="{{ route('users.store') }}">
@csrf
<!-- User name -->
<div>
<x-label for="username" :value="__('User name')" />
<x-input id="username" class="block mt-1 w-full" type="text" name="username" :value="old('username')" required autofocus />
</div>
<!-- Name -->
<div>
<x-label for="name" :value="__('Name')" />
<x-input id="name" class="block mt-1 w-full" type="text" name="name" :value="old('name')" required />
</div>
<!-- Email Address -->
<div class="mt-4">
<x-label for="email" :value="__('Email')" />
<x-input id="email" class="block mt-1 w-full" type="email" name="email" :value="old('email')" required />
</div>
<!-- Password -->
<div class="mt-4">
<x-label for="password" :value="__('Password')" />
<x-input id="password" class="block mt-1 w-full" type="password" name="password" required autocomplete="new-password" />
</div>
<!-- Confirm Password -->
<div class="mt-4">
<x-label for="password_confirmation" :value="__('Confirm Password')" />
<x-input id="password_confirmation" class="block mt-1 w-full" type="password" name="password_confirmation" required />
</div>
<div class="flex items-center justify-end mt-4">
<x-button class="ml-4">
{{ __('Register') }}
</x-button>
</div>
</form>
</div>
</div>
</div>
</div>
</x-app-layout>

View File

@@ -0,0 +1,54 @@
<x-app-layout>
<x-slot name="header">
<h2 class="font-semibold text-xl text-gray-800 leading-tight">
{{ __('Edit user') }}
</h2>
</x-slot>
<div class="py-12">
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
<div class="bg-white overflow-hidden shadow-sm sm:rounded-lg">
<div class="p-6 bg-white border-b border-gray-200">
<x-auth-validation-errors class="mb-4" :errors="$errors" />
<form method="POST" action="{{ route('users.update', $user->id) }}">
@csrf
@method('PUT')
<!-- User name -->
<!-- <input type="hidden" name="id" id="id" value="{{ $user->id}}"> -->
<div>
<x-label for="username" :value="__('User name')" />
<x-input id="username" class="block mt-1 w-full" type="text" name="username" value="{{ $user->username }}" required autofocus />
</div>
<!-- Name -->
<div>
<x-label for="name" :value="__('Name')" />
<x-input id="name" class="block mt-1 w-full" type="text" name="name" value="{{ $user->name }}" required />
</div>
<!-- Email Address -->
<div class="mt-4">
<x-label for="email" :value="__('Email')" />
<x-input id="email" class="block mt-1 w-full" type="email" name="email" value="{{ $user->email }}" required />
</div>
<div class="flex items-center justify-end mt-4">
<!-- <button type="submit" class="btn">{{ __('Save') }}</button> -->
<x-button class="ml-4">
{{ __('Save') }}
</x-button>
<!-- <a href="{{ route('users.index') }}">
<x-button class="ml-4">
{{ __('Cancel') }}
</x-button>
</a> -->
</div>
</form>
</div>
</div>
</div>
</div>
</x-app-layout>

View File

@@ -0,0 +1,47 @@
<x-app-layout>
<x-slot name="header">
<h2 class="font-semibold text-xl text-gray-800 leading-tight">
{{ __('Project list') }}
</h2>
</x-slot>
<div class="py-12">
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
<div class="bg-white overflow-hidden shadow-sm sm:rounded-lg">
<div class="p-6 bg-white border-b border-gray-200">
<a href="{{ route('projects.create')}}">
<x-button class="m-2">{{__('Create project')}}</x-button>
</a>
<div align="center">
<table class="table table-sm border-b border-gray-200">
<tr class="border border-gray-200">
<th class="p-2 border border-gray-200">
{{ __('Title')}}
</th>
<th class="p-2 border border-gray-200">
{{ __('Comment')}}
</th>
<th class="p-2 border border-gray-200">
{{ __('Actions')}}
</th>
</tr>
@forelse ( $projects as $project)
<tr class="border border-gray-200">
<td class="p-2 border border-gray-200">{{ $project->name }}</td>
<td class="p-2 border border-gray-200">{{ $project->description }}</td>
<td class="p-2 border border-gray-200">&nbsp;</td>
</tr>
@empty
<tr>
<td colspan="3">No Projects!</td>
</tr>
@endforelse
</table>
</div>
</div>
</div>
</div>
</div>
</x-app-layout>

View File

@@ -0,0 +1,53 @@
<x-app-layout>
<x-slot name="header">
<h2 class="font-semibold text-xl text-gray-800 leading-tight">
{{ __('Show user') }}
</h2>
</x-slot>
<div class="py-12">
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
<div class="bg-white overflow-hidden shadow-sm sm:rounded-lg">
<div class="p-6 bg-white border-b border-gray-200">
<!-- <form method="POST" action="{{ route('users.store') }}"> -->
<!-- @csrf -->
<!-- User name -->
<div>
<x-label for="username" :value="__('User name')" />
<x-input id="username" class="block mt-1 w-full" type="text" name="username" value="{{ $user->username }}" readonly />
</div>
<!-- Name -->
<div>
<x-label for="name" :value="__('Name')" />
<x-input id="name" class="block mt-1 w-full" type="text" name="name" value="{{ $user->name }}" readonly />
</div>
<!-- Email Address -->
<div class="mt-4">
<x-label for="email" :value="__('Email')" />
<x-input id="email" class="block mt-1 w-full" type="email" name="email" value="{{ $user->email }}" readonly />
</div>
<div class="flex items-center justify-end mt-4">
<a href="{{ route('users.edit',$user->id) }}">
<x-button class="ml-4">
{{ __('Edit user') }}
</x-button>
</a>
<a href="{{ route('users.index') }}">
<x-button class="ml-4">
{{ __('Cancel') }}
</x-button>
</a>
</div>
<!-- </form> -->
</div>
</div>
</div>
</div>
</x-app-layout>

View File

@@ -2,6 +2,7 @@
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\UserController;
use App\Http\Controllers\ProjectController;
/*
|--------------------------------------------------------------------------
@@ -22,15 +23,13 @@ Route::get('/dashboard', function () {
return view('dashboard');
})->middleware(['auth'])->name('dashboard');
// Route::resource('/users', UserController::class)->middleware(['auth']);
// Users
Route::prefix('admin')->middleware(['admin'])->group(function () {
Route::resource('/users', UserController::class);
});
// Route::prefix('admin')->group(function () {
// Route::resource('/users', UserController::class);
// });
// Projects
Route::resource('/projects', ProjectController::class)->middleware(['auth']);
require __DIR__ . '/auth.php';