birzha-legalizasia/app/Http/Controllers/API/ResourceController.php

63 lines
1.7 KiB
PHP
Executable File

<?php
namespace App\Http\Controllers\API;
use App\Http\Resources\CountryResource;
use App\Http\Resources\CategoryResource;
use App\Models\Country;
use App\Models\Category;
use App\Http\Controllers\Controller;
use App\Http\Resources\QuestionResource;
use App\Models\Account;
use App\Models\Application;
use App\Models\Question;
use Illuminate\Http\Request;
class ResourceController extends Controller
{
public function countries()
{
return CountryResource::collection(Country::all());
}
public function categories()
{
return CategoryResource::collection(Category::all());
}
public function faqs()
{
return QuestionResource::collection(Question::all());//todo investigate do we need all??
}
public function previewAccountAdmin($id)
{
$account = Account::with(['country','profile','clients','applications'])//tormoz etdirer todo fix this
->find($id);
return view('admin.preview',[
'account' => $account
]);
}
public function previewApplicationAdmin($id){
$application = Application::with(['account', 'attachments', 'ticket'])->find($id);
return view('admin.application_preview',[
'application' => $application
]);
}
public function approveApplication(Request $request){
$application = Application::find($request->id);
$application->state = 'approved';
$application->save();
$account = Account::find($application->account_id);
$account->legalization_number = $request->legalization_number;
$account->expires_at = $request->expires_at;
$account->save();
return redirect()->back();
}
}