Removed all controller and view files related to Colors, Filaments, Filament Types, and Manufacturers.
This commit is contained in:
@@ -1,91 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Color;
|
||||
|
||||
class ColorController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
// List all colors
|
||||
$colors = Color::all();
|
||||
return view('colors.index', compact('colors'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
// Create a new color
|
||||
return view('colors.create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
// Store a new color
|
||||
$request->validate([
|
||||
'name' => 'required|string|max:255',
|
||||
'hex' => 'required|string|max:255'
|
||||
]);
|
||||
|
||||
$color = new Color();
|
||||
$color->name = $request->name;
|
||||
$color->hex = $request->hex;
|
||||
$color->save();
|
||||
|
||||
return redirect()->route('colors.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
public function show(string $id)
|
||||
{
|
||||
// show single color
|
||||
$color = Color::find($id);
|
||||
return view('colors.show', compact('color'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit(string $id)
|
||||
{
|
||||
// edit color
|
||||
$color = Color::find($id);
|
||||
return view('colors.edit', compact('color'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, string $id)
|
||||
{
|
||||
// update color
|
||||
$color = Color::find($id);
|
||||
$color->name = $request->name;
|
||||
$color->hex = $request->hex;
|
||||
$color->save();
|
||||
return redirect()->route('colors.show', $color->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy(string $id)
|
||||
{
|
||||
// delete color
|
||||
$color = Color::find($id);
|
||||
$color->delete();
|
||||
return redirect()->route('colors.index');
|
||||
}
|
||||
}
|
||||
@@ -1,143 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Filament;
|
||||
use App\Models\Color;
|
||||
use App\Models\FilamentType;
|
||||
use App\Models\Manufacturer;
|
||||
|
||||
class FilamentController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
// show all filaments
|
||||
$filaments = Filament::all();
|
||||
$manufacturers = Manufacturer::all();
|
||||
return view('filaments.index', ['filaments' => $filaments, 'manufacturers' => $manufacturers]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
// create a new filament
|
||||
$manufacturers = Manufacturer::all();
|
||||
$types = FilamentType::all();
|
||||
$colors = Color::all();
|
||||
return view('filaments.create', compact('manufacturers', 'types', 'colors'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
// store a new filament
|
||||
$request->validate([
|
||||
'name' => 'required|string|max:255',
|
||||
'description' => 'nullable|string',
|
||||
'color_id' => 'required|exists:colors,id',
|
||||
'type_id' => 'required|exists:filament_types,id',
|
||||
'manufacturer_id' => 'required|exists:manufacturers,id',
|
||||
'weight' => 'required|numeric',
|
||||
'price' => 'nullable|decimal:2',
|
||||
'diameter' => 'required|decimal:2',
|
||||
'stock' => 'required|integer'
|
||||
]);
|
||||
|
||||
$filament = new Filament();
|
||||
$filament->name = $request->name;
|
||||
$filament->description = $request->description;
|
||||
$filament->color_id = $request->color_id;
|
||||
$filament->type_id = $request->type_id;
|
||||
$filament->manufacturer_id = $request->manufacturer_id;
|
||||
$filament->weight = $request->weight;
|
||||
$filament->price = $request->price;
|
||||
$filament->diameter = $request->diameter;
|
||||
$filament->stock = $request->stock;
|
||||
$filament->save();
|
||||
|
||||
ManufacturerController::refresh();
|
||||
return redirect()->route('filaments.index')->with('success', 'Filament created successfully.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
public function show(string $id)
|
||||
{
|
||||
// show a specific filament
|
||||
$filament = Filament::find($id);
|
||||
$manufacturer = Manufacturer::find($filament->manufacturer_id);
|
||||
$type = FilamentType::find($filament->type_id);
|
||||
$color = Color::find($filament->color_id);
|
||||
return view('filaments.show', compact('filament', 'manufacturer', 'type', 'color'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit(string $id)
|
||||
{
|
||||
// edit a specific filament
|
||||
$filament = Filament::find($id);
|
||||
$manufacturers = Manufacturer::all();
|
||||
$types = FilamentType::all();
|
||||
$colors = Color::all();
|
||||
return view('filaments.edit', compact('filament', 'manufacturers', 'types', 'colors'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, string $id)
|
||||
{
|
||||
// update a specific filament
|
||||
$request->validate([
|
||||
'name' => 'required|string|max:255',
|
||||
'description' => 'nullable|string',
|
||||
'color_id' => 'required|exists:colors,id',
|
||||
'type_id' => 'required|exists:filament_types,id',
|
||||
'manufacturer_id' => 'required|exists:manufacturers,id',
|
||||
'weight' => 'required|numeric',
|
||||
'price' => 'nullable|decimal:2',
|
||||
'diameter' => 'required|decimal:2',
|
||||
'stock' => 'required|integer'
|
||||
]);
|
||||
|
||||
$filament = Filament::find($id);
|
||||
$filament->name = $request->name;
|
||||
$filament->description = $request->description;
|
||||
$filament->color_id = $request->color_id;
|
||||
$filament->type_id = $request->type_id;
|
||||
$filament->manufacturer_id = $request->manufacturer_id;
|
||||
$filament->weight = $request->weight;
|
||||
$filament->price = $request->price;
|
||||
$filament->diameter = $request->diameter;
|
||||
$filament->stock = $request->stock;
|
||||
$filament->save();
|
||||
|
||||
ManufacturerController::refresh();
|
||||
|
||||
return redirect()->route('filaments.show', $filament->id)->with('success', 'Filament updated successfully.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy(string $id)
|
||||
{
|
||||
// delete a specific filament
|
||||
$filament = Filament::find($id);
|
||||
$filament->delete();
|
||||
|
||||
ManufacturerController::refresh();
|
||||
return redirect()->route('filaments.index')->with('success', 'Filament deleted successfully.');
|
||||
}
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\FilamentType;
|
||||
|
||||
class FilamentTypeController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$types = FilamentType::all();
|
||||
return view('types.index', compact('types'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
return view('types.create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
$type = new FilamentType();
|
||||
$type->name = $request->name;
|
||||
$type->description = $request->description;
|
||||
$type->save();
|
||||
return redirect()->route('types.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
public function show(string $id)
|
||||
{
|
||||
// Show Single Type
|
||||
$type = FilamentType::find($id);
|
||||
|
||||
|
||||
return view('types.show', compact('type'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit(string $id)
|
||||
{
|
||||
//
|
||||
$type = FilamentType::find($id);
|
||||
return view('types.edit', compact('type'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, string $id)
|
||||
{
|
||||
// Store updated type
|
||||
$type = FilamentType::find($id);
|
||||
$type->name = $request->name;
|
||||
$type->description = $request->description;
|
||||
$type->save();
|
||||
return redirect()->route('types.show', $type->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy(string $id)
|
||||
{
|
||||
// Delete Type
|
||||
$type = FilamentType::find($id);
|
||||
$type->delete();
|
||||
return redirect()->route('types.index')->with('success','Type deleted successfully.');
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,106 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Manufacturer;
|
||||
use App\Models\Filament;
|
||||
|
||||
class ManufacturerController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
// show all manufacturers
|
||||
$manufacturers = Manufacturer::all()->sortBy('name');
|
||||
return view('manufacturers.index', compact('manufacturers'));
|
||||
}
|
||||
|
||||
public static function refresh()
|
||||
{
|
||||
foreach (Manufacturer::all() as $manufacturer) {
|
||||
$manufacturer->filament_count = Filament::all()->where('manufacturer_id', $manufacturer->id)->count();
|
||||
$manufacturer->save();
|
||||
}
|
||||
return redirect()->route('manufacturers.index')->with('success', 'Manufacturer count refreshed successfully.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
// create a new manufacturer
|
||||
return view('manufacturers.create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
// store a new manufacturer
|
||||
$request->validate([
|
||||
'name' => 'required|string|max:255'
|
||||
]);
|
||||
|
||||
$manufacturer = new Manufacturer();
|
||||
$manufacturer->name = $request->name;
|
||||
$manufacturer->description = $request->description;
|
||||
$manufacturer->website = $request->website;
|
||||
$manufacturer->save();
|
||||
|
||||
return redirect()->route('manufacturers.index')->with('success', 'Manufacturer created successfully.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
public function show(string $id)
|
||||
{
|
||||
// show a specific manufacturer
|
||||
$manufacturer = Manufacturer::find($id);
|
||||
return view('manufacturers.show', compact('manufacturer'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit(string $id)
|
||||
{
|
||||
// edit a specific manufacturer
|
||||
$manufacturer = Manufacturer::find($id);
|
||||
return view('manufacturers.edit', compact('manufacturer'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, string $id)
|
||||
{
|
||||
// update a specific manufacturer
|
||||
$request->validate([
|
||||
'name' => 'required|string|max:255'
|
||||
]);
|
||||
|
||||
$manufacturer = Manufacturer::find($id);
|
||||
$manufacturer->name = $request->name;
|
||||
$manufacturer->description = $request->description;
|
||||
$manufacturer->website = $request->website;
|
||||
$manufacturer->save();
|
||||
return redirect()->route('manufacturers.show', $manufacturer->id)->with('success', 'Manufacturer updated successfully.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy(string $id)
|
||||
{
|
||||
// delete a specific manufacturer
|
||||
$manufacturer = Manufacturer::find($id);
|
||||
$manufacturer->delete();
|
||||
return redirect()->route('manufacturers.index')->with('success', 'Manufacturer deleted successfully.');
|
||||
}
|
||||
}
|
||||
@@ -27,19 +27,21 @@ class Filament extends Component
|
||||
public $type_id = '';
|
||||
public $manufacturer_id = '';
|
||||
public $weight = '1000';
|
||||
public $finish = 'Basic';
|
||||
public $price = '0';
|
||||
public $stock = '0';
|
||||
|
||||
|
||||
public $search = '';
|
||||
|
||||
public $editid = '';
|
||||
public $deleteid = '';
|
||||
|
||||
|
||||
public function create() {
|
||||
@Auth::check();
|
||||
|
||||
// Validate
|
||||
$this->validate();
|
||||
$this->validate();
|
||||
|
||||
$filament = new Model();
|
||||
$filament->name = $this->name;
|
||||
@@ -47,8 +49,9 @@ class Filament extends Component
|
||||
$filament->diameter = $this->diameter;
|
||||
$filament->color_id = $this->color_id;
|
||||
$filament->filament_type_id = $this->type_id;
|
||||
$filament->manufacturer_id = $this->manufacturer_id;
|
||||
$filament->manufacturer_id = $this->manufacturer_id;
|
||||
$filament->weight = $this->weight;
|
||||
$filament->finish = $this->finish;
|
||||
$filament->price = $this->price;
|
||||
$filament->stock = $this->stock;
|
||||
$filament->save();
|
||||
@@ -75,28 +78,30 @@ class Filament extends Component
|
||||
$this->type_id = $filament->filament_type_id;
|
||||
$this->manufacturer_id = $filament->manufacturer_id;
|
||||
$this->weight = $filament->weight;
|
||||
$filament->finish = $this->finish;
|
||||
$this->price = $filament->price;
|
||||
$this->stock = $filament->stock;
|
||||
|
||||
|
||||
Flux::modal('editModal')->show();
|
||||
}
|
||||
public function save($editid) {
|
||||
@Auth::check();
|
||||
|
||||
|
||||
$filament = Model::findOrFail($editid);
|
||||
$filament->name = $this->name;
|
||||
$filament->description = $this->description;
|
||||
$filament->diameter = $this->diameter;
|
||||
$filament->color_id = $this->color_id;
|
||||
$filament->filament_type_id = $this->type_id;
|
||||
$filament->manufacturer_id = $this->manufacturer_id;
|
||||
$filament->manufacturer_id = $this->manufacturer_id;
|
||||
$filament->weight = $this->weight;
|
||||
$filament->finish = $this->finish;
|
||||
$filament->price = $this->price;
|
||||
$filament->stock = $this->stock;
|
||||
$filament->save();
|
||||
|
||||
$this->resetInputFields();
|
||||
|
||||
|
||||
Flux::modal('editModal')->close();
|
||||
}
|
||||
|
||||
@@ -114,6 +119,7 @@ class Filament extends Component
|
||||
$this->type_id = $filament->filament_type_id;
|
||||
$this->manufacturer_id = $filament->manufacturer_id;
|
||||
$this->weight = $filament->weight;
|
||||
$this->finish = $filament->finish;
|
||||
$this->price = $filament->price;
|
||||
$this->stock = $filament->stock;
|
||||
|
||||
@@ -136,7 +142,7 @@ class Filament extends Component
|
||||
Flux::modals()->close();
|
||||
}
|
||||
public function resetInputFields() {
|
||||
$this->reset(['name', 'description', 'diameter', 'color_id', 'type_id', 'manufacturer_id', 'weight', 'price', 'stock', 'deleteid', 'editid']);
|
||||
$this->reset(['name', 'description', 'diameter', 'color_id', 'type_id', 'manufacturer_id', 'weight', 'price', 'finish', 'deleteid', 'editid']);
|
||||
}
|
||||
public function render()
|
||||
{
|
||||
|
||||
@@ -9,6 +9,7 @@ use Livewire\Attributes\title;
|
||||
use Livewire\Attributes\Validate;
|
||||
use Flux\Flux;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use App\Models\Filament;
|
||||
|
||||
#[title('Manufacturer List')]
|
||||
class Manufacturer extends Component{
|
||||
@@ -30,7 +31,7 @@ class Manufacturer extends Component{
|
||||
|
||||
|
||||
// Validate
|
||||
$this->validate();
|
||||
$this->validate();
|
||||
|
||||
$manufacturer = new Model();
|
||||
$manufacturer->name = $this->name;
|
||||
@@ -55,12 +56,12 @@ class Manufacturer extends Component{
|
||||
$this->name = $manufacturer->name;
|
||||
$this->description = $manufacturer->description;
|
||||
$this->website = $manufacturer->website;
|
||||
|
||||
|
||||
Flux::modal('editModal')->show();
|
||||
}
|
||||
public function save($editid) {
|
||||
@Auth::check();
|
||||
|
||||
|
||||
$manufacturer = Model::findOrFail($editid);
|
||||
$manufacturer->name = $this->name;
|
||||
$manufacturer->description = $this->description;
|
||||
@@ -68,7 +69,7 @@ class Manufacturer extends Component{
|
||||
$manufacturer->save();
|
||||
|
||||
$this->resetInputFields();
|
||||
|
||||
|
||||
Flux::modal('editModal')->close();
|
||||
}
|
||||
public function deleteModal($manufacturerid) {
|
||||
@@ -105,6 +106,7 @@ class Manufacturer extends Component{
|
||||
|
||||
public function render()
|
||||
{
|
||||
|
||||
return view('livewire.filament.manufacturer', [
|
||||
'manufacturers' => Model::search('name', $this->search)->paginate(10)
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user