refactoring fix lint Department resource

This commit is contained in:
aslan 2024-02-12 10:39:46 +03:00
parent 7d4461e231
commit 1091847227
8 changed files with 15 additions and 26 deletions

View File

@ -7,19 +7,11 @@ use Illuminate\Foundation\Http\FormRequest;
class StoreDepartmentRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, ValidationRule|array|string>
*/
public function rules(): array
{
return [

View File

@ -2,7 +2,6 @@
namespace App\Http\Requests\admin\Catalog;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Foundation\Http\FormRequest;
class UpdateDepartmentRequest extends FormRequest

View File

@ -3,8 +3,6 @@
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;
class DepartmentFactory extends Factory
{

View File

@ -6,9 +6,6 @@ use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('departments', function (Blueprint $table) {
@ -22,9 +19,6 @@ return new class extends Migration
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('departments');

View File

@ -2,17 +2,12 @@
namespace Database\Seeders;
use App\Models\Department;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class DepartmentSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
DB::table('departments')->insert([

View File

@ -1,6 +1,5 @@
@extends('layouts.admin-layout')
@section('content')
@auth()
<div class="row">
<div class="col">
@ -53,6 +52,18 @@
{{ $errors->first('educational_institution_id') }}
@endif
</div>
<div class="mt-3">
{{ Form::label('slug', 'URL') }}
</div>
<div class="mt-1">
{{ Form::text('slug', $department->slug, ['class' => 'form-control']) }}
</div>
<div>
@if ($errors->any())
{{ $errors->first('slug') }}
@endif
</div>
<div class="mt-3">
{{ Form::submit('Изменить', ['class' => 'btn btn-primary']) }}
</div>

View File

@ -9,7 +9,6 @@
<table class="table">
<thead class="border-b-2 border-solid border-black text-left" style="text-align: left">
<tr>
<th scope="col">Позиция</th>
<th scope="col">Название</th>
<th scope="col">Описание</th>
@ -41,5 +40,4 @@
<br>
<br>
</div>
@endsection

View File

@ -18,6 +18,7 @@ class DepartmentTest extends TestCase
parent::setUp();
EducationalInstitution::factory()->create();
Faculty::factory()->create();
$this->department = Department::factory()->create();
$this->data = Department::factory()->make()->only([
'position',
@ -26,12 +27,14 @@ class DepartmentTest extends TestCase
'slug',
'faculty_id',
]);
$this->user = User::factory()->create([
'name' => 'admin',
'email' => 'test@example.com',
'password' => 123456
]);
}
public function testIndexDepartmentsPage(): void
{
$response = $this->actingAs($this->user)
@ -90,7 +93,6 @@ class DepartmentTest extends TestCase
$this->assertDatabaseHas('departments', $this->data);
}
public function testDestroyDepartment(): void
{
$response = $this->actingAs($this->user)