Initial commit
This commit is contained in:
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Customer;
|
||||
use App\Media;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Services\CustomerService;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
class CustomersController extends Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
$this->customerService = New CustomerService();
|
||||
}
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$search = false;
|
||||
return view('customers.index',compact('search'));
|
||||
}
|
||||
|
||||
public function info(){
|
||||
return view('customers.info');
|
||||
}
|
||||
|
||||
public function search(Request $request){
|
||||
$noic = $request->noic;
|
||||
$customer_info = $this->customerService->getCustomerInfo($noic);
|
||||
$search = true;
|
||||
if($customer_info){
|
||||
Session::put('customer_info',$customer_info);
|
||||
return redirect()->route('customer_info')->with( ['customer_info' => $customer_info] );
|
||||
}else{
|
||||
return view('customers.index',compact('customer_info','search','noic'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create(Request $request)
|
||||
{
|
||||
// dd($request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$customer = $this->customerService->createNewCustomer($request);
|
||||
|
||||
$customer_info = Customer::where('noic','=',$request['noic'])->first();
|
||||
|
||||
// dd($customer_info);
|
||||
Session::put('customer_info',$customer_info);
|
||||
return redirect()->route('customer_info')->with( ['customer_info' => $customer_info] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param \App\Customer $customer
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show(Customer $customer)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\Customer $customer
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit(Customer $customer)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \App\Customer $customer
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, Customer $customer)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Customer $customer
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(Customer $customer)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function test(){
|
||||
$response = Http::get('http://localhost:8000/api/customers');
|
||||
dd($response->json());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user