style updates
This commit is contained in:
@@ -10,18 +10,51 @@ use Modules\Banners\Models\Banner;
|
||||
|
||||
final class BannerController extends Controller
|
||||
{
|
||||
public function index(): View { return view('banners::admin.index', ['records' => Banner::query()->latest()->paginate(20)]); }
|
||||
public function create(): View { return view('banners::admin.form'); }
|
||||
public function store(Request $request): RedirectResponse { $data = $request->validate(['title' => ['required', 'string', 'max:255'],
|
||||
public function index(): View
|
||||
{
|
||||
return view('banners::admin.index', ['records' => Banner::query()->latest()->paginate(20)]);
|
||||
}
|
||||
|
||||
public function create(): View
|
||||
{
|
||||
return view('banners::admin.form');
|
||||
}
|
||||
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
$data = $request->validate(['title' => ['required', 'string', 'max:255'],
|
||||
'content' => ['nullable', 'string'],
|
||||
'link_url' => ['nullable', 'string'],
|
||||
'position' => ['required', 'string', 'max:255'],
|
||||
'enabled' => ['sometimes', 'boolean']]); $data['enabled'] = $request->boolean('enabled'); Banner::create($data); return redirect()->route('banners.index')->with('status', 'Banner created.'); }
|
||||
public function edit(Banner $banner): View { return view('banners::admin.form', ['record' => $banner]); }
|
||||
public function update(Request $request, Banner $banner): RedirectResponse { $data = $request->validate(['title' => ['required', 'string', 'max:255'],
|
||||
'enabled' => ['sometimes', 'boolean']]);
|
||||
$data['enabled'] = $request->boolean('enabled');
|
||||
Banner::create($data);
|
||||
|
||||
return redirect()->route('banners.index')->with('status', 'Banner created.');
|
||||
}
|
||||
|
||||
public function edit(Banner $banner): View
|
||||
{
|
||||
return view('banners::admin.form', ['record' => $banner]);
|
||||
}
|
||||
|
||||
public function update(Request $request, Banner $banner): RedirectResponse
|
||||
{
|
||||
$data = $request->validate(['title' => ['required', 'string', 'max:255'],
|
||||
'content' => ['nullable', 'string'],
|
||||
'link_url' => ['nullable', 'string'],
|
||||
'position' => ['required', 'string', 'max:255'],
|
||||
'enabled' => ['sometimes', 'boolean']]); $data['enabled'] = $request->boolean('enabled'); $banner->update($data); return redirect()->route('banners.index')->with('status', 'Banner updated.'); }
|
||||
public function destroy(Banner $banner): RedirectResponse { $banner->delete(); return back()->with('status', 'Banner deleted.'); }
|
||||
'enabled' => ['sometimes', 'boolean']]);
|
||||
$data['enabled'] = $request->boolean('enabled');
|
||||
$banner->update($data);
|
||||
|
||||
return redirect()->route('banners.index')->with('status', 'Banner updated.');
|
||||
}
|
||||
|
||||
public function destroy(Banner $banner): RedirectResponse
|
||||
{
|
||||
$banner->delete();
|
||||
|
||||
return back()->with('status', 'Banner deleted.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,11 +9,15 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
final class Banner extends Model
|
||||
{
|
||||
use HasFactory, SoftDeletes;
|
||||
protected $table = 'banners';
|
||||
protected $fillable = ['title', 'content', 'link_url', 'position', 'enabled'];
|
||||
|
||||
protected function casts(): array { return [
|
||||
'enabled' => 'boolean'
|
||||
]; }
|
||||
|
||||
protected $table = 'banners';
|
||||
|
||||
protected $fillable = ['title', 'content', 'link_url', 'position', 'enabled'];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'enabled' => 'boolean',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,4 +2,15 @@
|
||||
|
||||
namespace Modules\Banners\Support;
|
||||
|
||||
final class ModuleInfo { public static function name(): string { return 'Banners'; } public static function nameLower(): string { return 'banners'; } }
|
||||
final class ModuleInfo
|
||||
{
|
||||
public static function name(): string
|
||||
{
|
||||
return 'Banners';
|
||||
}
|
||||
|
||||
public static function nameLower(): string
|
||||
{
|
||||
return 'banners';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,4 +2,6 @@
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
it('registers the Banners administration route', function (): void { expect(Route::has('administration.banners.index'))->toBeTrue(); });
|
||||
it('registers the Banners administration route', function (): void {
|
||||
expect(Route::has('administration.banners.index'))->toBeTrue();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user