add resource Documents Online

This commit is contained in:
aslan 2024-01-19 19:15:45 +03:00
parent 88c692bfe1
commit ff2deace3e
12 changed files with 97 additions and 93 deletions

View File

@ -1,65 +0,0 @@
<?php
namespace App\Http\Controllers;
use App\Http\Requests\StoreDocumentsOnlineRequest;
use App\Http\Requests\UpdateDocumentsOnlineRequest;
use App\Models\DocumentsOnline;
use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\View\View;
use Illuminate\Foundation\Application;
use Illuminate\Support\Facades\Auth;
class DocumentsOnlineController extends Controller
{
public function index()
{
$documentsOnline = DocumentsOnline::all();
return view('documents-online.index', compact('documentsOnline'));
}
public function create(DocumentsOnline $documentOnline): View
{
if (Auth::guest()) {
abort(403);
}
$parent = $documentOnline;
return view('documents-online', compact('parent'));
}
public function store(StoreDocumentsOnlineRequest $request)
{
}
/**
* Display the specified resource.
*/
public function show(DocumentsOnline $doceumentsOnline)
{
//
}
/**
* Show the form for editing the specified resource.
*/
public function edit(DocumentsOnline $doceumentsOnline)
{
//
}
/**
* Update the specified resource in storage.
*/
public function update(UpdateDocumentsOnlineRequest $request, DocumentsOnline $doceumentsOnline)
{
//
}
/**
* Remove the specified resource from storage.
*/
public function destroy(DocumentsOnline $doceumentsOnline)
{
//
}
}

View File

@ -0,0 +1,65 @@
<?php
namespace App\Http\Controllers;
use App\Http\Requests\StoreOnlineDocumentsRequest;
use App\Http\Requests\UpdateOnlineDocumentsRequest;
use App\Models\OnlineDocuments;
use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\View\View;
use Illuminate\Foundation\Application;
use Illuminate\Support\Facades\Auth;
class OnlineDocumentsController extends Controller
{
public function index()
{
$onlineDocuments = OnlineDocuments::all();
return view('online-documents.index', compact('onlineDocuments'));
}
public function create(OnlineDocuments $documentOnline): View
{
if (Auth::guest()) {
abort(403);
}
$parent = $documentOnline;
return view('online-documents', compact('parent'));
}
public function store(StoreOnlineDocumentsRequest $request)
{
}
/**
* Display the specified resource.
*/
public function show(OnlineDocuments $doceumentsOnline)
{
//
}
/**
* Show the form for editing the specified resource.
*/
public function edit(OnlineDocuments $doceumentsOnline)
{
//
}
/**
* Update the specified resource in storage.
*/
public function update(UpdateOnlineDocumentsRequest $request, OnlineDocuments $doceumentsOnline)
{
//
}
/**
* Remove the specified resource from storage.
*/
public function destroy(OnlineDocuments $doceumentsOnline)
{
//
}
}

View File

@ -4,7 +4,7 @@ namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest; use Illuminate\Foundation\Http\FormRequest;
class StoreDocumentsOnlineRequest extends FormRequest class StoreOnlineDocumentsRequest extends FormRequest
{ {
/** /**
* Determine if the user is authorized to make this request. * Determine if the user is authorized to make this request.

View File

@ -4,7 +4,7 @@ namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest; use Illuminate\Foundation\Http\FormRequest;
class UpdateDocumentsOnlineRequest extends FormRequest class UpdateOnlineDocumentsRequest extends FormRequest
{ {
/** /**
* Determine if the user is authorized to make this request. * Determine if the user is authorized to make this request.

View File

@ -5,14 +5,15 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
class DocumentsOnline extends Model class OnlineDocuments extends Model
{ {
use HasFactory; use HasFactory;
protected $fillable = [ protected $fillable = [
'id', 'id',
'name', 'name',
'description', 'url',
'url' 'parent',
'children'
]; ];
} }

View File

@ -2,11 +2,11 @@
namespace App\Policies; namespace App\Policies;
use App\Models\DocumentsOnline; use App\Models\OnlineDocuments;
use App\Models\User; use App\Models\User;
use Illuminate\Auth\Access\Response; use Illuminate\Auth\Access\Response;
class DocumentsOnlinePolicy class OnlineDocumentsPolicy
{ {
/** /**
* Determine whether the user can view any models. * Determine whether the user can view any models.
@ -19,7 +19,7 @@ class DocumentsOnlinePolicy
/** /**
* Determine whether the user can view the model. * Determine whether the user can view the model.
*/ */
public function view(User $user, DocumentsOnline $doceumentsOnline): bool public function view(User $user, OnlineDocuments $doceumentsOnline): bool
{ {
// //
} }
@ -35,7 +35,7 @@ class DocumentsOnlinePolicy
/** /**
* Determine whether the user can update the model. * Determine whether the user can update the model.
*/ */
public function update(User $user, DocumentsOnline $doceumentsOnline): bool public function update(User $user, OnlineDocuments $doceumentsOnline): bool
{ {
// //
} }
@ -43,7 +43,7 @@ class DocumentsOnlinePolicy
/** /**
* Determine whether the user can delete the model. * Determine whether the user can delete the model.
*/ */
public function delete(User $user, DocumentsOnline $doceumentsOnline): bool public function delete(User $user, OnlineDocuments $doceumentsOnline): bool
{ {
// //
} }
@ -51,7 +51,7 @@ class DocumentsOnlinePolicy
/** /**
* Determine whether the user can restore the model. * Determine whether the user can restore the model.
*/ */
public function restore(User $user, DocumentsOnline $doceumentsOnline): bool public function restore(User $user, OnlineDocuments $doceumentsOnline): bool
{ {
// //
} }
@ -59,7 +59,7 @@ class DocumentsOnlinePolicy
/** /**
* Determine whether the user can permanently delete the model. * Determine whether the user can permanently delete the model.
*/ */
public function forceDelete(User $user, DocumentsOnline $doceumentsOnline): bool public function forceDelete(User $user, OnlineDocuments $doceumentsOnline): bool
{ {
// //
} }

View File

@ -5,7 +5,7 @@ namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory; use Illuminate\Database\Eloquent\Factories\Factory;
/** /**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\DocumentsOnline> * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\OnlineDocuments>
*/ */
class DocumentsOnlineFactory extends Factory class DocumentsOnlineFactory extends Factory
{ {

View File

@ -20,8 +20,8 @@ class DatabaseSeeder extends Seeder
'email' => 'test@example.com', 'email' => 'test@example.com',
'password' => 123456 'password' => 123456
]); ]);
// $this->call([ $this->call([
// DocumentsOnlineSeeder::class OnlineDocumentsSeeder::class
// ]); ]);
} }
} }

View File

@ -7,14 +7,14 @@ use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder; use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
class DocumentsOnlineSeeder extends Seeder class OnlineDocumentsSeeder extends Seeder
{ {
/** /**
* Run the database seeds. * Run the database seeds.
*/ */
public function run(): void public function run(): void
{ {
DB::table('documents_online')->insert([ DB::table('online_documents')->insert([
[ [
'name' => 'Подать документы онлайн', 'name' => 'Подать документы онлайн',
'url' => '', 'url' => '',

View File

@ -1,8 +0,0 @@
@extends('layouts.admin-layout')
@section('content')
@foreach($documentsOnline as $documentOnline)
{{ $documentOnline->name }}
{{ $documentOnline->url }}
{{ $documentOnline->description }}
@endforeach
@endsection

View File

@ -0,0 +1,11 @@
@extends('layouts.admin-layout')
@section('content')
@foreach($onlineDocuments as $onlineDocument)
<div>
{{ $onlineDocument->name }}
{{ $onlineDocument->url }}
{{ $onlineDocument->parent }}
{{ $onlineDocument->children }}
</div>
@endforeach
@endsection

View File

@ -1,6 +1,6 @@
<?php <?php
use App\Http\Controllers\DocumentsOnlineController; use App\Http\Controllers\OnlineDocumentsController;
use App\Http\Controllers\ProfileController; use App\Http\Controllers\ProfileController;
use App\Http\Controllers\UploadFileController; use App\Http\Controllers\UploadFileController;
use App\Http\Controllers\UserController; use App\Http\Controllers\UserController;
@ -23,7 +23,7 @@ Route::get('/', function () {
Route::resources([ Route::resources([
'/users' => UserController::class, '/users' => UserController::class,
'/documents-online' => DocumentsOnlineController::class '/online-documents' => OnlineDocumentsController::class
]); ]);
Route::get('/course', function () { Route::get('/course', function () {