redo deli info testing

This commit is contained in:
Zain Fauzan Rofie Azizi
2018-06-25 16:43:19 +08:00
parent 48e033f436
commit 0a93a6b9fe
5 changed files with 79 additions and 59 deletions
@@ -4,6 +4,8 @@ namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Deliveryinfo;
use App\User;
use App\Company;
use Auth;
class DeliveryinfoController extends Controller
@@ -11,6 +13,11 @@ class DeliveryinfoController extends Controller
public function index()
{
$deliveryinfo = Deliveryinfo::where('com_id', Auth::user()->company())->get();
if (!$deliveryinfo)
{
return response()->json(['message'=>'Access Denied!'], 404);
}
return response()->json($deliveryinfo, 200);
}
@@ -23,7 +30,18 @@ class DeliveryinfoController extends Controller
*/
public function show(Deliveryinfo $id)
{
$deliveryinfo = Deliveryinfo::where('com_id', Auth::user()->company())->where('id', $id)->firstOrFail();
$deliveryinfo = Deliveryinfo::where('com_id', Auth::user()->company())->where('id', $id)->first();
if (!$deliveryinfo)
{
return response()->json(['message'=>'Access Denied!'], 404);
}
$deliveryinfos = DB::table('deliveryinfos')
->select('id', 'branch', 'deli_info', 'address', 'city', 'postcode', 'state', 'country', 'contact_person', 'contact_person_no', 'com_id')
->where('com_id', Auth::user()->company())
->get();
return response()->json($deliveryinfo, 200);
}