ok
This commit is contained in:
44
app/Http/Controllers/Api/ContactUsController.php
Normal file
44
app/Http/Controllers/Api/ContactUsController.php
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Api;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\CMS\ContactUs;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
|
class ContactUsController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Store contact us message
|
||||||
|
*/
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
$data = $request->validate([
|
||||||
|
/**
|
||||||
|
* Message Title
|
||||||
|
*
|
||||||
|
* @example Salam
|
||||||
|
*/
|
||||||
|
'title' => ['required', 'string', 'max:255'],
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Message content
|
||||||
|
*
|
||||||
|
* @example Bet app
|
||||||
|
*/
|
||||||
|
'message' => ['required', 'string', 'max:255'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
ContactUs::forceCreate(
|
||||||
|
...$data,
|
||||||
|
...[
|
||||||
|
'user_id' => auth()->id(),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'message' => __('Successfully created'),
|
||||||
|
], 201);
|
||||||
|
}
|
||||||
|
}
|
||||||
19
app/Models/CMS/ContactUs.php
Normal file
19
app/Models/CMS/ContactUs.php
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models\CMS;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @property int $id
|
||||||
|
* @property int $user_id
|
||||||
|
* @property string $title
|
||||||
|
* @property string $message
|
||||||
|
* @property \Illuminate\Support\Facades\Date $created_at
|
||||||
|
* @property \Illuminate\Support\Facades\Date $updated_at
|
||||||
|
*/
|
||||||
|
class ContactUs extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('contact_us', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string('title');
|
||||||
|
$table->text('message');
|
||||||
|
|
||||||
|
$table->foreignId('user_id')->nullable()->constrained()->nullOnDelete();
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('contact_us');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -6,6 +6,7 @@ use App\Http\Controllers\Api\CardOrder\CardOrderController;
|
|||||||
use App\Http\Controllers\Api\CardPin\CardPinController;
|
use App\Http\Controllers\Api\CardPin\CardPinController;
|
||||||
use App\Http\Controllers\Api\CardRequisite\CardRequisiteController;
|
use App\Http\Controllers\Api\CardRequisite\CardRequisiteController;
|
||||||
use App\Http\Controllers\Api\CardTransaction\CardTransactionsController;
|
use App\Http\Controllers\Api\CardTransaction\CardTransactionsController;
|
||||||
|
use App\Http\Controllers\Api\ContactUsController;
|
||||||
use App\Http\Controllers\Api\FetchLoanHistoryController;
|
use App\Http\Controllers\Api\FetchLoanHistoryController;
|
||||||
use App\Http\Controllers\Api\LoanOrder\Remaining\LoanOrderRemainingOrderController;
|
use App\Http\Controllers\Api\LoanOrder\Remaining\LoanOrderRemainingOrderController;
|
||||||
use App\Http\Controllers\Api\LoanPaidOffLetterOrderController;
|
use App\Http\Controllers\Api\LoanPaidOffLetterOrderController;
|
||||||
@@ -63,6 +64,8 @@ Route::get('provinces', [ProvinceController::class, 'index']);
|
|||||||
Route::get('base-app-enums', [BaseAppEnumController::class, 'index']);
|
Route::get('base-app-enums', [BaseAppEnumController::class, 'index']);
|
||||||
|
|
||||||
Route::middleware(['auth:sanctum', 'not_banned'])->group(function () {
|
Route::middleware(['auth:sanctum', 'not_banned'])->group(function () {
|
||||||
|
Route::post('contact-us', [ContactUsController::class, 'store']);
|
||||||
|
|
||||||
// Profile... [tested fully]
|
// Profile... [tested fully]
|
||||||
Route::get('profile', [ProfileController::class, 'index']);
|
Route::get('profile', [ProfileController::class, 'index']);
|
||||||
Route::post('profile', [ProfileController::class, 'store']);
|
Route::post('profile', [ProfileController::class, 'store']);
|
||||||
|
|||||||
Reference in New Issue
Block a user