first change
This commit is contained in:
0
Modules/Resume/app/Http/Controllers/.gitkeep
Normal file
0
Modules/Resume/app/Http/Controllers/.gitkeep
Normal file
125
Modules/Resume/app/Http/Controllers/ResumeController.php
Normal file
125
Modules/Resume/app/Http/Controllers/ResumeController.php
Normal file
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Resume\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Dotlogics\Grapesjs\App\Traits\EditorTrait;
|
||||
use Illuminate\Http\Request;
|
||||
use Modules\Resume\Models\Resume;
|
||||
use Yajra\DataTables\Facades\DataTables;
|
||||
|
||||
class ResumeController extends Controller
|
||||
{
|
||||
use EditorTrait;
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
|
||||
public function editor(Request $request, Resume $resume): mixed
|
||||
{
|
||||
return $this->show_gjs_editor($request, $resume);
|
||||
}
|
||||
public function index()
|
||||
{
|
||||
if (request()->ajax()) {
|
||||
$model = Resume::query()->latest();
|
||||
return DataTables::eloquent($model)
|
||||
->addIndexColumn()
|
||||
->setRowClass('tableRow')
|
||||
->editColumn('status', function (Resume $resume) {
|
||||
$status = $resume->status ? 'Published' : 'Draft';
|
||||
$color = $resume->status ? 'text-success' : 'text-danger';
|
||||
return "<p class='{$color}'>{$status}</p>";
|
||||
})
|
||||
->editColumn('created_at', '{!! getFormatted(date:$created_at) !!}')
|
||||
->addColumn('action', 'resume::resume.datatable.action')
|
||||
->rawColumns(['status', 'action'])
|
||||
->toJson();
|
||||
}
|
||||
|
||||
return view('resume::resume.index', [
|
||||
'title' => 'Resume List',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$isEditing = $request->has('id');
|
||||
|
||||
if ($isEditing) {
|
||||
$resume = Resume::findOrFail($request->id);
|
||||
}
|
||||
|
||||
$validated = $request->validate([
|
||||
'name' => [
|
||||
'required',
|
||||
'string',
|
||||
'max:255',
|
||||
],
|
||||
'status' => ['nullable', 'integer'],
|
||||
]);
|
||||
|
||||
if ($isEditing) {
|
||||
$resume->update($validated);
|
||||
} else {
|
||||
$resume = Resume::create($validated);
|
||||
}
|
||||
|
||||
$message = $isEditing ? "Resume setting for {$resume->title} has been updated." : "Resume setting for {$resume->title} has been created.";
|
||||
flash()->success($message);
|
||||
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
$resume = Resume::findOrFail($id);
|
||||
return view('resume::resume.show', [
|
||||
'resume' => $resume,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$resume = Resume::findOrFail($id);
|
||||
return view('resume::resume.partials._form', [
|
||||
'editable' => true,
|
||||
'resume' => $resume,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
$resume = Resume::findOrFail($id);
|
||||
$resume->delete();
|
||||
return response()->json(['status' => 200, 'message' => "Resume has been deleted."], 200);
|
||||
}
|
||||
}
|
26
Modules/Resume/app/Models/Resume.php
Normal file
26
Modules/Resume/app/Models/Resume.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Resume\Models;
|
||||
|
||||
use Dotlogics\Grapesjs\App\Contracts\Editable;
|
||||
use Dotlogics\Grapesjs\App\Traits\EditableTrait;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
// use Modules\Resume\Database\Factories\ResumeFactory;
|
||||
|
||||
class Resume extends Model implements Editable
|
||||
{
|
||||
use HasFactory, EditableTrait;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'student_id',
|
||||
'gjs_data',
|
||||
'status',
|
||||
'createdby',
|
||||
'updatedby',
|
||||
];
|
||||
}
|
0
Modules/Resume/app/Models/Scopes/.gitkeep
Normal file
0
Modules/Resume/app/Models/Scopes/.gitkeep
Normal file
0
Modules/Resume/app/Providers/.gitkeep
Normal file
0
Modules/Resume/app/Providers/.gitkeep
Normal file
30
Modules/Resume/app/Providers/EventServiceProvider.php
Normal file
30
Modules/Resume/app/Providers/EventServiceProvider.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Resume\Providers;
|
||||
|
||||
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
||||
|
||||
class EventServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The event handler mappings for the application.
|
||||
*
|
||||
* @var array<string, array<int, string>>
|
||||
*/
|
||||
protected $listen = [];
|
||||
|
||||
/**
|
||||
* Indicates if events should be discovered.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected static $shouldDiscoverEvents = true;
|
||||
|
||||
/**
|
||||
* Configure the proper event listeners for email verification.
|
||||
*/
|
||||
protected function configureEmailVerification(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
118
Modules/Resume/app/Providers/ResumeServiceProvider.php
Normal file
118
Modules/Resume/app/Providers/ResumeServiceProvider.php
Normal file
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Resume\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Blade;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Nwidart\Modules\Traits\PathNamespace;
|
||||
|
||||
class ResumeServiceProvider extends ServiceProvider
|
||||
{
|
||||
use PathNamespace;
|
||||
|
||||
protected string $name = 'Resume';
|
||||
|
||||
protected string $nameLower = 'resume';
|
||||
|
||||
/**
|
||||
* Boot the application events.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
$this->registerCommands();
|
||||
$this->registerCommandSchedules();
|
||||
$this->registerTranslations();
|
||||
$this->registerConfig();
|
||||
$this->registerViews();
|
||||
$this->loadMigrationsFrom(module_path($this->name, 'database/migrations'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the service provider.
|
||||
*/
|
||||
public function register(): void
|
||||
{
|
||||
$this->app->register(EventServiceProvider::class);
|
||||
$this->app->register(RouteServiceProvider::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register commands in the format of Command::class
|
||||
*/
|
||||
protected function registerCommands(): void
|
||||
{
|
||||
// $this->commands([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register command Schedules.
|
||||
*/
|
||||
protected function registerCommandSchedules(): void
|
||||
{
|
||||
// $this->app->booted(function () {
|
||||
// $schedule = $this->app->make(Schedule::class);
|
||||
// $schedule->command('inspire')->hourly();
|
||||
// });
|
||||
}
|
||||
|
||||
/**
|
||||
* Register translations.
|
||||
*/
|
||||
public function registerTranslations(): void
|
||||
{
|
||||
$langPath = resource_path('lang/modules/'.$this->nameLower);
|
||||
|
||||
if (is_dir($langPath)) {
|
||||
$this->loadTranslationsFrom($langPath, $this->nameLower);
|
||||
$this->loadJsonTranslationsFrom($langPath);
|
||||
} else {
|
||||
$this->loadTranslationsFrom(module_path($this->name, 'lang'), $this->nameLower);
|
||||
$this->loadJsonTranslationsFrom(module_path($this->name, 'lang'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register config.
|
||||
*/
|
||||
protected function registerConfig(): void
|
||||
{
|
||||
$this->publishes([module_path($this->name, 'config/config.php') => config_path($this->nameLower.'.php')], 'config');
|
||||
$this->mergeConfigFrom(module_path($this->name, 'config/config.php'), $this->nameLower);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register views.
|
||||
*/
|
||||
public function registerViews(): void
|
||||
{
|
||||
$viewPath = resource_path('views/modules/'.$this->nameLower);
|
||||
$sourcePath = module_path($this->name, 'resources/views');
|
||||
|
||||
$this->publishes([$sourcePath => $viewPath], ['views', $this->nameLower.'-module-views']);
|
||||
|
||||
$this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->nameLower);
|
||||
|
||||
$componentNamespace = $this->module_namespace($this->name, $this->app_path(config('modules.paths.generator.component-class.path')));
|
||||
Blade::componentNamespace($componentNamespace, $this->nameLower);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the services provided by the provider.
|
||||
*/
|
||||
public function provides(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
private function getPublishableViewPaths(): array
|
||||
{
|
||||
$paths = [];
|
||||
foreach (config('view.paths') as $path) {
|
||||
if (is_dir($path.'/modules/'.$this->nameLower)) {
|
||||
$paths[] = $path.'/modules/'.$this->nameLower;
|
||||
}
|
||||
}
|
||||
|
||||
return $paths;
|
||||
}
|
||||
}
|
50
Modules/Resume/app/Providers/RouteServiceProvider.php
Normal file
50
Modules/Resume/app/Providers/RouteServiceProvider.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Resume\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||
|
||||
class RouteServiceProvider extends ServiceProvider
|
||||
{
|
||||
protected string $name = 'Resume';
|
||||
|
||||
/**
|
||||
* Called before routes are registered.
|
||||
*
|
||||
* Register any model bindings or pattern based filters.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
parent::boot();
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the routes for the application.
|
||||
*/
|
||||
public function map(): void
|
||||
{
|
||||
$this->mapApiRoutes();
|
||||
$this->mapWebRoutes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the "web" routes for the application.
|
||||
*
|
||||
* These routes all receive session state, CSRF protection, etc.
|
||||
*/
|
||||
protected function mapWebRoutes(): void
|
||||
{
|
||||
Route::middleware('web')->group(module_path($this->name, '/routes/web.php'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the "api" routes for the application.
|
||||
*
|
||||
* These routes are typically stateless.
|
||||
*/
|
||||
protected function mapApiRoutes(): void
|
||||
{
|
||||
Route::middleware('api')->prefix('api')->name('api.')->group(module_path($this->name, '/routes/api.php'));
|
||||
}
|
||||
}
|
0
Modules/Resume/app/Services/.gitkeep
Normal file
0
Modules/Resume/app/Services/.gitkeep
Normal file
Reference in New Issue
Block a user