style updates
This commit is contained in:
@@ -1,2 +1,3 @@
|
||||
<?php
|
||||
|
||||
return ['name' => 'Careers'];
|
||||
|
||||
@@ -1,3 +1,43 @@
|
||||
<?php
|
||||
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema;
|
||||
return new class extends Migration { public function up(): void { Schema::create('career_jobs',function(Blueprint $t): void{$t->id();$t->string('title');$t->string('slug')->unique();$t->string('department')->nullable();$t->string('location')->nullable();$t->string('employment_type')->default('full-time');$t->longText('description')->nullable();$t->string('status')->default('draft')->index();$t->timestamp('published_at')->nullable();$t->timestamp('closes_at')->nullable();$t->timestamps();}); Schema::create('career_applications',function(Blueprint $t): void{$t->id();$t->foreignId('job_id')->constrained('career_jobs')->cascadeOnDelete();$t->string('name');$t->string('email')->index();$t->string('phone')->nullable();$t->string('cv_path')->nullable();$t->text('cover_letter')->nullable();$t->string('status')->default('new')->index();$t->text('notes')->nullable();$t->timestamps();}); } public function down(): void { Schema::dropIfExists('career_applications');Schema::dropIfExists('career_jobs'); } };
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('career_jobs', function (Blueprint $t): void {
|
||||
$t->id();
|
||||
$t->string('title');
|
||||
$t->string('slug')->unique();
|
||||
$t->string('department')->nullable();
|
||||
$t->string('location')->nullable();
|
||||
$t->string('employment_type')->default('full-time');
|
||||
$t->longText('description')->nullable();
|
||||
$t->string('status')->default('draft')->index();
|
||||
$t->timestamp('published_at')->nullable();
|
||||
$t->timestamp('closes_at')->nullable();
|
||||
$t->timestamps();
|
||||
});
|
||||
Schema::create('career_applications', function (Blueprint $t): void {
|
||||
$t->id();
|
||||
$t->foreignId('job_id')->constrained('career_jobs')->cascadeOnDelete();
|
||||
$t->string('name');
|
||||
$t->string('email')->index();
|
||||
$t->string('phone')->nullable();
|
||||
$t->string('cv_path')->nullable();
|
||||
$t->text('cover_letter')->nullable();
|
||||
$t->string('status')->default('new')->index();
|
||||
$t->text('notes')->nullable();
|
||||
$t->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('career_applications');
|
||||
Schema::dropIfExists('career_jobs');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,3 +1,32 @@
|
||||
<?php
|
||||
namespace Modules\Careers\Http\Controllers; use App\Http\Controllers\Controller; use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; use Illuminate\View\View; use Modules\Careers\Models\Job; use Modules\Careers\Models\Application;
|
||||
final class CareerController extends Controller { public function index(): View { return view('careers::admin.index',['jobs'=>Job::withCount('applications')->latest()->paginate(20),'applications'=>Application::latest()->limit(10)->get()]); } public function store(Request $r): RedirectResponse { Job::create($r->validate(['title'=>['required','string','max:255'],'slug'=>['required','string','max:255','unique:career_jobs,slug'],'department'=>['nullable','string','max:120'],'location'=>['nullable','string','max:120'],'employment_type'=>['required','in:full-time,part-time,contract,temporary,internship'],'description'=>['nullable','string'],'status'=>['required','in:draft,published,closed'],'published_at'=>['nullable','date'],'closes_at'=>['nullable','date','after:published_at']])); return back()->with('status','Job created.'); } public function destroy(Job $job): RedirectResponse { $job->delete(); return back()->with('status','Job deleted.'); } }
|
||||
|
||||
namespace Modules\Careers\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
use Modules\Careers\Models\Application;
|
||||
use Modules\Careers\Models\Job;
|
||||
|
||||
final class CareerController extends Controller
|
||||
{
|
||||
public function index(): View
|
||||
{
|
||||
return view('careers::admin.index', ['jobs' => Job::withCount('applications')->latest()->paginate(20), 'applications' => Application::latest()->limit(10)->get()]);
|
||||
}
|
||||
|
||||
public function store(Request $r): RedirectResponse
|
||||
{
|
||||
Job::create($r->validate(['title' => ['required', 'string', 'max:255'], 'slug' => ['required', 'string', 'max:255', 'unique:career_jobs,slug'], 'department' => ['nullable', 'string', 'max:120'], 'location' => ['nullable', 'string', 'max:120'], 'employment_type' => ['required', 'in:full-time,part-time,contract,temporary,internship'], 'description' => ['nullable', 'string'], 'status' => ['required', 'in:draft,published,closed'], 'published_at' => ['nullable', 'date'], 'closes_at' => ['nullable', 'date', 'after:published_at']]));
|
||||
|
||||
return back()->with('status', 'Job created.');
|
||||
}
|
||||
|
||||
public function destroy(Job $job): RedirectResponse
|
||||
{
|
||||
$job->delete();
|
||||
|
||||
return back()->with('status', 'Job deleted.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
<?php
|
||||
namespace Modules\Careers\Models; use Illuminate\Database\Eloquent\Model;
|
||||
final class Application extends Model { protected $table='career_applications'; protected $fillable=['job_id','name','email','phone','cv_path','cover_letter','status','notes']; }
|
||||
|
||||
namespace Modules\Careers\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
final class Application extends Model
|
||||
{
|
||||
protected $table = 'career_applications';
|
||||
|
||||
protected $fillable = ['job_id', 'name', 'email', 'phone', 'cv_path', 'cover_letter', 'status', 'notes'];
|
||||
}
|
||||
|
||||
@@ -1,3 +1,23 @@
|
||||
<?php
|
||||
namespace Modules\Careers\Models; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
final class Job extends Model { protected $table='career_jobs'; protected $fillable=['title','slug','department','location','employment_type','description','status','published_at','closes_at']; protected function casts(): array { return ['published_at'=>'datetime','closes_at'=>'datetime']; } public function applications(): HasMany { return $this->hasMany(Application::class); } }
|
||||
|
||||
namespace Modules\Careers\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
final class Job extends Model
|
||||
{
|
||||
protected $table = 'career_jobs';
|
||||
|
||||
protected $fillable = ['title', 'slug', 'department', 'location', 'employment_type', 'description', 'status', 'published_at', 'closes_at'];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return ['published_at' => 'datetime', 'closes_at' => 'datetime'];
|
||||
}
|
||||
|
||||
public function applications(): HasMany
|
||||
{
|
||||
return $this->hasMany(Application::class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Careers\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
final class CareersServiceProvider extends ServiceProvider
|
||||
{
|
||||
public function register(): void
|
||||
@@ -8,6 +11,7 @@ final class CareersServiceProvider extends ServiceProvider
|
||||
$this->app->register(RouteServiceProvider::class);
|
||||
$this->mergeConfigFrom(module_path('Careers', 'Config/config.php'), 'careers');
|
||||
}
|
||||
|
||||
public function boot(): void
|
||||
{
|
||||
$this->loadMigrationsFrom(module_path('Careers', 'Database/Migrations'));
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Careers\Providers;
|
||||
|
||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
final class RouteServiceProvider extends ServiceProvider
|
||||
{
|
||||
public function boot(): void
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
<?php
|
||||
use Illuminate\Support\Facades\Route; use Modules\Careers\Http\Controllers\CareerController;
|
||||
Route::middleware(['auth','verified'])->prefix('administration/careers')->name('administration.careers.')->group(function(): void { Route::get('/',[CareerController::class,'index'])->name('index'); Route::post('/',[CareerController::class,'store'])->name('store'); Route::delete('/{job}',[CareerController::class,'destroy'])->name('destroy'); });
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Modules\Careers\Http\Controllers\CareerController;
|
||||
|
||||
Route::middleware(['auth', 'verified'])->prefix('administration/careers')->name('administration.careers.')->group(function (): void {
|
||||
Route::get('/', [CareerController::class, 'index'])->name('index');
|
||||
Route::post('/', [CareerController::class, 'store'])->name('store');
|
||||
Route::delete('/{job}', [CareerController::class, 'destroy'])->name('destroy');
|
||||
});
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Careers\Tests\Feature;
|
||||
|
||||
use Tests\TestCase;
|
||||
|
||||
final class ModuleBootTest extends TestCase
|
||||
{
|
||||
public function test_module_configuration_is_available(): void
|
||||
|
||||
Reference in New Issue
Block a user