• 1000 1004 * AnnoncesController. php
public function store(Request $request)
{
// Salarie::create($request->all());
$Annonce = new Annonce($request->all());
//$Annonce->user_id = Auth::user()->id;
$Annonce->save();
session()->flash('success','Annonce add successfully');
return redirect('annonces');
}
2020_05_31_164745_create_category_table. php
public function up()
{
Schema::create('category', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name')->unique();
$table->string('slug')->unique();
$table->string('image')->nullable();
$table->timestamps();
});
}
2020_06_22_152000_create_annonces_table
public function up()
{
Schema::create('annonces', function (Blueprint $table) {
$table->bigIncrements('id');
$table->bigInteger('category_id')->unsigned()->nullable();
$table->foreign('category_id')->references('id')
->on('category')->onDelete('cascade');
$table->bigInteger('souscategory_id')->unsigned()->nullable();
$table->foreign('souscategory_id')->references('id')
->on('souscategories')->onDelete('cascade');
$table->boolean('type')->default(false);
$table->text('images');
$table->timestamps();
});
}
2020_06_22_151000_create_souscategories_table. php
public function up()
{
Schema::create('souscategories', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('souscategorie')->unique();
$table->string('slug')->unique();
$table->bigInteger('category_id')->unsigned()->nullable();
$table->foreign('category_id')->references('id')
->on('category')->onDelete('cascade');
$table->timestamps();
});
}