#Making a dashboard into a project
5 messages · Page 1 of 1 (latest)
this is exactly what i did
i make a migration and a seeder
migration code:
namespace Database\Seeders;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('products', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('imgpath');
$table->decimal('Price');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('products');
}
};
and this is the seeder code:
<?php
namespace Database\Seeders;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB; // Add this line to import the DB facade
class ProductsSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
DB::table('products')->insert([
[
'name' => 'بيتزا',
'price' => 13,
'imgpath' => 'img/Pizza.png', // Relative path from the public directory
'created_at' => now(),
'updated_at' => now(),
],
]);
}
}
and this is the route code
<?php
use Illuminate\Support\Facades\Route;
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider and all of them will
| be assigned to the "web" middleware group. Make something great!
|
*/
Route::get('/', function () {
return view('public');
})->name('public');
Route::get('/Products', function () {
$result = DB::table('Products')->get();
return view('Products', ['Products' => $result]);
})->name('Products');
Route::get('/checkout', function () {
return view('checkout');
})->name('checkout');
Auth::routes();
Route::get('/home', [App\Http\Controllers\HomeController::class, 'index'])->name('home');
and then i make the laravel ui so when i type /login it will redirect me to the login page
everything is good at this moment i just wanna make a dashboard into a very basic project that makes the user can change a product name and price and can insert image and if he got an order it will show him in the dashboard to confirm it I try to do it but I couldn't