Schema::create('user_categories', function (Blueprint $table) {
$table->increments('id');
$table->unsignedInteger('user_id');
$table->foreign('user_id')->references('id')->on('users');
$table->unsignedInteger('category_id');
$table->foreign('category_id')->references('id')->on('categories');
$table->timestamps();
});
Schema::create('categories', function (Blueprint $table) {
$table->increments('id');
$table->string('title_ru', 50);
$table->string('title_en', 50);
$table->string('slug', 50);
$table->timestamps();
});
$user_category = new UserCategory();
$user_category->user_id = Auth::user()->id();
$user_category->category_id = $request->category_id;
if ($user_category->save()) {
return response()->json(['response' => 'success']);
}