Merge branch 'develop' into feature/CreateDocumention
# Conflicts: # backend/app/User/Controllers/Dashboard/ConfirmController.php # backend/app/User/Controllers/Dashboard/DocumentationController.php
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,2 +1,3 @@
|
||||
.idea
|
||||
.env
|
||||
front
|
||||
@@ -16,12 +16,14 @@ class DocumentationController extends Controller
|
||||
public function index(Request $request): array
|
||||
{
|
||||
return DataTableFacade::run(
|
||||
User::query()->with('documentations'),
|
||||
User::query()->with('documents'),
|
||||
$request,
|
||||
allowedFilters: ['*'],
|
||||
allowedSortings: ['*'],
|
||||
allowedSelects: [
|
||||
'user.id', 'user.username'
|
||||
'users.id', 'users.first_name', 'users.last_name', 'users.national_id',
|
||||
'users.phone_number', 'users.postal_code', 'users.city_id', 'users.province_id',
|
||||
'users.province_name', 'users.city_name', 'users.address', 'documents.title', 'documents.url'
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,11 +2,14 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Database\Factories\CityFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class City extends Model
|
||||
{
|
||||
/** @use HasFactory<\Database\Factories\CityFactory> */
|
||||
/** @use HasFactory<CityFactory> */
|
||||
use HasFactory;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
}
|
||||
|
||||
@@ -2,11 +2,29 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Database\Factories\DocumentFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class Document extends Model
|
||||
{
|
||||
/** @use HasFactory<\Database\Factories\DocumentFactory> */
|
||||
/** @use HasFactory<DocumentFactory> */
|
||||
use HasFactory;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
|
||||
public function documentable(): MorphTo
|
||||
{
|
||||
return $this->morphTo();
|
||||
}
|
||||
|
||||
protected function url(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn($value) => Storage::disk('public')->url($value)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
15
backend/app/Models/Expert.php
Normal file
15
backend/app/Models/Expert.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Database\Factories\ExpertFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Expert extends Model
|
||||
{
|
||||
/** @use HasFactory<ExpertFactory> */
|
||||
use HasFactory;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
}
|
||||
@@ -2,11 +2,14 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Database\Factories\ProvinceFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Province extends Model
|
||||
{
|
||||
/** @use HasFactory<\Database\Factories\ProvinceFactory> */
|
||||
/** @use HasFactory<ProvinceFactory> */
|
||||
use HasFactory;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ use Database\Factories\UserFactory;
|
||||
use Illuminate\Database\Eloquent\Attributes\Guarded;
|
||||
use Illuminate\Database\Eloquent\Attributes\Hidden;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphToMany;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Laravel\Passport\HasApiTokens;
|
||||
@@ -18,4 +19,9 @@ class User extends Authenticatable
|
||||
/** @use HasFactory<UserFactory> */
|
||||
use HasFactory, Notifiable, HasApiTokens;
|
||||
protected $guarded = ['id'];
|
||||
|
||||
public function documents(): MorphToMany
|
||||
{
|
||||
return $this->morphToMany(Document::class, 'documentable');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\User\Controller;
|
||||
namespace App\User\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\User;
|
||||
14
backend/app/User/Controllers/Dashboard/ConfirmController.php
Executable file
14
backend/app/User/Controllers/Dashboard/ConfirmController.php
Executable file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\User\Controllers\Dashboard;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ConfirmController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\User\Controller;
|
||||
namespace App\User\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Traits\ApiResponse;
|
||||
@@ -10,6 +10,12 @@ return Application::configure(basePath: dirname(__DIR__))
|
||||
api: __DIR__.'/../routes/api.php',
|
||||
commands: __DIR__.'/../routes/console.php',
|
||||
health: '/up',
|
||||
then: function () {
|
||||
Route::middleware('web')
|
||||
->prefix('expert')
|
||||
->name('expert.')
|
||||
->group(base_path('routes/expert.php'));
|
||||
},
|
||||
)
|
||||
->withMiddleware(function (Middleware $middleware): void {
|
||||
$middleware->web()->preventRequestForgery(['*']);
|
||||
|
||||
24
backend/database/factories/ExpertFactory.php
Normal file
24
backend/database/factories/ExpertFactory.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Expert;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends Factory<Expert>
|
||||
*/
|
||||
class ExpertFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -29,7 +29,6 @@ return new class extends Migration
|
||||
$table->string('province_name')->nullable();
|
||||
$table->foreignId('city_id')->nullable()->constrained('cities');
|
||||
$table->string('city_name')->nullable();
|
||||
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('experts', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('username');
|
||||
$table->string('first_name')->nullable();
|
||||
$table->string('last_name')->nullable();
|
||||
$table->string('email')->unique();
|
||||
$table->string('password');
|
||||
$table->string('national_id')->nullable();
|
||||
$table->string('phone_number')->nullable();
|
||||
$table->foreignId('province_id')->nullable()->constrained('provinces');
|
||||
$table->string('province_name')->nullable();
|
||||
$table->foreignId('city_id')->nullable()->constrained('cities');
|
||||
$table->string('city_name')->nullable();
|
||||
$table->tinyInteger('level')->default(1);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('experts');
|
||||
}
|
||||
};
|
||||
17
backend/database/seeders/ExpertSeeder.php
Normal file
17
backend/database/seeders/ExpertSeeder.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class ExpertSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
12
backend/routes/expert.php
Executable file
12
backend/routes/expert.php
Executable file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
use App\Admin\Controllers\DocumentationController;
|
||||
|
||||
Route::prefix('documents')
|
||||
->name('documents.')
|
||||
->controller(DocumentationController::class)
|
||||
->group(function () {
|
||||
Route::post('/', 'index')->name('index');
|
||||
Route::post('confirm', 'confirm')->name('confirm');
|
||||
Route::post('reject', 'reject')->name('reject');
|
||||
});
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
use App\User\Controller\AuthController;
|
||||
use App\User\Controller\ProfileController;
|
||||
use App\User\Controllers\AuthController;
|
||||
use App\User\Controllers\ProfileController;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
Route::prefix('auth')
|
||||
|
||||
Reference in New Issue
Block a user