gestionale2025/app/Http/Controllers/ImportRuleController.php

83 lines
1.8 KiB
PHP

<?php
namespace App\Http\Controllers;
use App\Models\Categorie;
use App\Models\ImportRule;
use Illuminate\Http\Request;
class ImportRuleController extends Controller
{
/**
* Display a listing of the resource.
*/
public function index()
{
//
$rules = ImportRule::all();
return view('import_rules.index', compact('rules'));
}
/**
* Show the form for creating a new resource.
*/
public function create()
{
//
// Return a view to create a new import rule
$categorie = Categorie::all();
return view('import_rules.create',compact('categorie'));
//'categories'=>$categorie);
}
/**
* Store a newly created resource in storage.
*/
public function store(Request $request)
{
//
$request->validate([
'pattern' => 'required|string|max:255',
'category_id' => 'required|exists:categories,id',
'description' => 'nullable|string|max:255',
'is_active' => 'boolean',
'created_by' => 'nullable|string|max:255',
]);
ImportRule::create($request->all());
return redirect()->route('import_rules.index'); // Redirect to the index after storing the rule
}
/**
* Display the specified resource.
*/
public function show(ImportRule $importRule)
{
//
}
/**
* Show the form for editing the specified resource.
*/
public function edit(ImportRule $importRule)
{
//
}
/**
* Update the specified resource in storage.
*/
public function update(Request $request, ImportRule $importRule)
{
//
}
/**
* Remove the specified resource from storage.
*/
public function destroy(ImportRule $importRule)
{
//
}
}