app/Http/Controllers/TenancyController.php
/**
     * @param Tenancy $tenancy
     * @return JsonResponse|View
     * @throws AuthorizationException
     */
@param Tenancy $tenancy
@return JsonResponse|View
@throws AuthorizationException
@param Tenancy $tenancy @return JsonResponse|View @throws AuthorizationException
public function edit(Tenancy $tenancy)
    {
        $this->authorize('update', $tenancy);
        $properties = Property::where('user_id', $tenancy->user_id)->pluck('name_en', 'id');
        $tenants = Tenant::where('user_id', $tenancy->user_id)->pluck('name', 'id');
        if (request()->ajax()) {
            return Response::json([
                'properties' => $properties,
                'tenants' => $tenants,
                'tenancy' => $tenancy
            ]);
        }
        return view('tenancy.edit');
    }
public function edit ( Tenancy $ tenancy ) { $ this -> authorize ( 'update' , $ tenancy ) ; $ properties = Property :: where ( 'user_id' , $ tenancy -> user_id ) -> pluck ( 'name_en' , 'id' ) ; $ tenants = Tenant :: where ( 'user_id' , $ tenancy -> user_id ) -> pluck ( 'name' , 'id' ) ; if ( request ( ) -> ajax ( ) ) { return Response :: json ( [ 'properties' => $ properties , 'tenants' => $ tenants , 'tenancy' => $ tenancy ] ) ; } return view ( 'tenancy.edit' ) ; }
@param Tenancy $tenancy
 @return JsonResponse|View
 @throws AuthorizationException
@param Tenancy $tenancy @return JsonResponse|View @throws AuthorizationException